You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Ahmad Rabab’ah <aR...@bi-bst.com> on 2017/04/16 07:31:26 UTC

Sequence Id in entity

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 .



Re: Sequence Id in entity

Posted by Aditya Sharma <ad...@hotwaxsystems.com>.
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 .
>
>
>

Re: Sequence Id in entity

Posted by Jacques Le Roux <ja...@les7arts.com>.
Hi Ahmad,

Please use rather user ML for such questions, see why here http://ofbiz.apache.org/mailing-lists.html
You will get a better support and it's more fair to share with everybody

The wider the audience the better the answers you might get

Thanks

Jacques


Le 16/04/2017  09:31, Ahmad Rababah a crit :
> 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 .
>
>
>