two
ways of doing this...
1. map
your ejb pk to another ejb. The counter.jar does this. It creates a long for
every "beantype". See the faq at www.orionserver.com. I think there is
something under http://www.orionsupport.com/articles/ejbuniquecounter.html, also. In your ejbCreate(), get a
reference to the counter.jar, and then ask for the new pk :
long id =
com.evermind.ejb.CounterUtils.getNextID("java:comp/env/ejb/Counter",
"mybeanname");
2. See
the chain of articles by Brett McGlaughlin at http://www.flashline.com/content/community.jsp?sid=989854104625-1090580543-153#brett. Instead of using an ejb to generate your
pk references, use jdbc and a stateless session bean. In the end you do the same
thing in your ejbCreate():
long id = slsbRemote.getNextID("mybeanname");
And
whatever you do, stay away from triggers.
Regards,
the
elephantwalker
|
- Generating primary keys Sergei Batiuk
- RE: Generating primary keys elephantwalker
- RE: Generating primary keys Jeff Schnitzer
- Re: Generating primary keys Joni Suominen