Dev - Entity primary key generation

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

Dev - Entity primary key generation

Antero Lukkonen
Hello!

First of all i would like to apologize if it's a stupid question, but i
have not been able to find an answer by my self.

Is it possible to generate a primary_key id automatically. Does ofbiz
provide some standard method in minilang or by entity definition or do i
have to write the method myself and assign the value returned prior to
database insert to the object? The id would just be an unique
identificator like a sequence in Postgres or auto_increment in mysql.

Regards
Antero Lukkonen
Monit Solutions
Estonia

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Dev - Entity primary key generation

Jacopo Cappellato
Hi Antero,

you can use the sequenced-id-to-env command:

<sequenced-id-to-env sequence-name="EntityName" env-name="newKeyId"/>

Jacopo

Antero Lukkonen wrote:

> Hello!
>
> First of all i would like to apologize if it's a stupid question, but i
> have not been able to find an answer by my self.
>
> Is it possible to generate a primary_key id automatically. Does ofbiz
> provide some standard method in minilang or by entity definition or do i
> have to write the method myself and assign the value returned prior to
> database insert to the object? The id would just be an unique
> identificator like a sequence in Postgres or auto_increment in mysql.
>
> Regards
> Antero Lukkonen
> Monit Solutions
> Estonia
>
>  
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Dev - Entity primary key generation

Si Chen-2
In reply to this post by Antero Lukkonen
Yes, minilang already does this with sequenced-id-to-env, and there is
Java API GenericDelegator.getNextSeqId() as well.  It is based on what's
stored in SequenceValueItem.  Si

Antero Lukkonen wrote:

> Hello!
>
> First of all i would like to apologize if it's a stupid question, but i
> have not been able to find an answer by my self.
>
> Is it possible to generate a primary_key id automatically. Does ofbiz
> provide some standard method in minilang or by entity definition or do i
> have to write the method myself and assign the value returned prior to
> database insert to the object? The id would just be an unique
> identificator like a sequence in Postgres or auto_increment in mysql.
>
> Regards
> Antero Lukkonen
> Monit Solutions
> Estonia
>
>  
> _______________________________________________
> Dev mailing list
> [hidden email]
> http://lists.ofbiz.org/mailman/listinfo/dev
>
>
>  

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev