You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Aditya Sharma <ad...@hotwaxsystems.com> on 2017/04/16 13:44:43 UTC

Re: Sequence Id in entity

Hello Ahmad,

You can set primary key for a entity with *prim-key *element.

<prim-key field="field name"/>

For a particular *field* you can provide its *type*.

<field name="field name" type="id"></field>

You can refer to field types from *fieldtype*.xml* files where * will be
the name of the database used. For example for Mysql there will be a file
fieldtypemysql.xml.

For *identifier* type, underlying data-structure is *String* data type for
Java and *varchar* for database (You can refer fieldtype*.xml file). So
next sequence need to be generated during create operation. When using
*entity-auto* type services it is *handled internally* but if you are
creating *custom* service for create operation you need to *generate* that.

To generate the next sequence id in create service, getNextSeqId("Entity
Name") method of GenericDelegator is used.
For example:

partyId = delegator.getNextSeqId("Party")

It will generate the next sequence for the Party entity.

Thanks & Regards,
Aditya Sharma
Enterprise Software Engineer
HotWax Systems Pvt. Ltd.
http://www.hotwaxsystems.com/

On Sun, Apr 16, 2017 at 1:01 PM, Ahmad Rabab’ah <aR...@bi-bst.com> wrote:

> Hello Dears ,
>
> I have created new entitiy in CompnentName_entitymodel.xml
> and I define all filed, but I want to set the “id” as a primary key and
> sequence .
> how can I do that .?
>
> Thank you .
>
>
>