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
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Sergei Batiuk
Sent: Monday, May 14, 2001 10:08 AM
To: Orion-Interest
Subject: Generating primary keys

Hi mailing list,
 
I have the following problem: the primary key for my EJB is generated at the database level ( a trigger ), so I don't want to generate it in the ejbCreate() method. However, EJB specification says, that the use of the primary key is a MUST. Does anyone have the solution for this problem?
 
Any help is greatly appreciated.
 
Sergei.

Reply via email to