Hi Dan,

> If all you need to do is get your primary key from the autoincrement, 
> you can simply put the code to fetch the value in ejbCreate and return 
> that value as your primary key. Or am I missing something?

yes, I think so, Ray has essentially a CMP bean, and EJB spec 1.1
in section 9.5.2 figure 27 shows, that ejbCreate() is called before
the container accesses the DB; section 9.4.2 additionally says,
that ejbCreate(...) should be DECLARED to return the PK class but
actually to return null, as the container is required to ignore
that return value. If a DB autoincrement mechanism is desired at all
JAWS has to handle that (i.e. with JRun's EJB part, formerly known as
Ejipt, it is possible to configure many SQL statements to be executed
for every CMP action instead of only one, thus allowing an 'insert ...'
followed by a 'select ...' or a '...CURVAL...' or a stored procedure).

But from previous messages I believe, Ray was pointed to
theserverside.com (and there to something like the High-Low
key generating pattern) and interpreting Marcs answer in this
thread I'm pretty sure, this is the intention: the bean itself
creates a new key 'magically'.

What I think isn't needed for Rays problem is Marcs suggestion 
of a 'mixed mode'. SUN clearly has intended the ejbCreate(...)
method for proper initialization of all bean fields (section
9.4.2, 3rd paragraph) and has allowed ALL access as for every 
business method (EXCEPT ctx.getEJBObject() and 
ctx.getPrimaryKey(), which don't make too much sense here 
[section 9.1.6, Table 4]) in ejbCreate(). Thus Ray is free to 
implement whatever he needs to compute a primary key and 
assign it to his PK field(s), including access to some
DataSource and incrementing/reading DB values from it, as some
key generating mechanisms require (section 9.1.6, Table 4 
definitely allows 'JNDI access to java:comp/env')!

But may be, I'm missing the point, do I?

my very best regards

Georg
 ___   ___
| + | |__    Georg Rehfeld      Woltmanstr. 12     20097 Hamburg
|_|_\ |___   [EMAIL PROTECTED]           +49 (40) 23 53 27 10



_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to