Brendan W.McAdams wrote:

I'm probably committing an egregious faux pas here by not digging through lists, etc. first but I'm interested in what the plans/status are for automatic key generation with CMPs are.


This is really part of OpenEJB Nova so you might want to take it to that list mailto:[EMAIL PROTECTED] but it is probably of interest here as well :)


Support for unknown-pk is crap right now - I knocked something together for ApacheCon that just used a random number but that is not a solution.

There are a few basic techniques that need to be covered:
1) pre-insert generation. This might just be other implementations
   of o.o.n.entity.cmp.PrimaryKeyFactory that generate a PK somehow,
   inject it into the InstanceData and return the value. Examples
   could be a caching hi-lo key generator or something that issued
   a JDBC operation to get the value

2) insert-side effect, where the value is generated as a consequence
   of performing the insert operation. Examples would be a MySQL auto-
   increment, JDBC getGeneratedKeys(), or Oracle with INSERT-RETURNING.
   The simple solution (KISS) is to always insert between ejbCreate and
   ejbPostCreate but that can mean some transactions insert then
   immediately update; the more complex solution would be to defer the
   insert for as long as possible, but that means being able to cope
   and reference to an EJB whose identity is not known. A compromise
   would be to delay until after ejbPostCreate which at least gives the
   user the chance to initialize any CMRs. This should be selectable by
   simply defining alternative VOPs for the create.

I'd start by having a look at the create VOPs and feel free to bounce any questions off the list.

Good luck!
--
Jeremy

Reply via email to