You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Patrick <pa...@gmail.com> on 2010/02/17 01:54:07 UTC
how to autogen a primary key instead of passing it in?
I have a Java service that creates a Facility. Right now I specify
the primary key (facilityId) manually. I would like the database to
automatically provide me with next available integer to use as the
primary key. How can I accomplish this in my java service?
UtilMisc.toMap( "facilityId", (Object)facilityId); //right now I am
passing in the pk but I want an automatically gen'd pk
Thank you very much in advance,
Patrick
Re: how to autogen a primary key instead of passing it in?
Posted by Scott Gray <sc...@hotwaxmedia.com>.
Hi Patrick,
Something like this should do the trick:
nextFacilityId = delegator.getNextSeqId("Facility");
Regards
Scott
HotWax Media
http://www.hotwaxmedia.com
On 16/02/2010, at 5:54 PM, Patrick wrote:
> I have a Java service that creates a Facility. Right now I specify
> the primary key (facilityId) manually. I would like the database to
> automatically provide me with next available integer to use as the
> primary key. How can I accomplish this in my java service?
>
> UtilMisc.toMap( "facilityId", (Object)facilityId); //right now I am
> passing in the pk but I want an automatically gen'd pk
>
> Thank you very much in advance,
> Patrick