Sequence Id in entity

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Sequence Id in entity

Ahmad Rabab’ah
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 .


Reply | Threaded
Open this post in threaded view
|

Re: Sequence Id in entity

Aditya Sharma
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 <[hidden email]> 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 .
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Sequence Id in entity

Jacques Le Roux
Administrator
In reply to this post by Ahmad Rabab’ah
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 Rabab’ah 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 .
>
>
>