> Hi All,
>
> I have a question regarding Creating CMP Entity EJBs.
> For several of our Entities, we use a sequence number generated by our
> database (Oracle) as a primary key.
> The problem is that our ejbCreate() method expects a primary key when
> invoked. Also, the persister generated create methods appear
> to be called
> before even the first line of the bean's ejbCreate().
The database isn't touched before ejbCreate() is called. See 9.5.2.
>
> To get around this, at the controller level, we were able to create a
> separate Connection, query the database for the next sequence
> number, close
> the connection, and then call the EJBHome Create() method
> passing in the
> sequence number.
> Although it works, this approach seems very clumsy and slow.
> There's got to
> be a better way,
> Perhaps where we don't even need a separate database connection.
>
One solution is to have a stateless session bean perform the steps you
outlined above. This bean can be called either by the entity's client,
passing the id thus obtained to the ejbCreate() method, or by ejbCreate()
itself.
Usually the unique id generator bean allocates IDs in batches to avoid
hitting the database for every object creation. This has some side effects,
for example losing the sequentiality of the IDs (they are still unique, of
course).
- Avi
--
s/\be(\w+)/e-\1/g;
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".