geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brendan W.McAdams <>
Subject Success (At Least Partially) with AutoKeyGen + CMP in Nova
Date Thu, 08 Jan 2004 22:56:27 GMT

I got a working instance (Test Case) of CMP working with Sybase ASE.  
Essentially, I changed the ejbCreate method to be a query instead of an 
update.  Immediately after the insert, it does a "select @@identity" 
which fetches the ID which was generated by the insert.  With a custom 
AutoGeneratedPKCreateMethod, modified slightly from CMPCreateMethod to 
use ejbCreate as a Query rather than an update.

For the record, this has to be done as part of ejbCreate, as ejbCreate 
is responsible according to specs and the monson-haefel book for 
creating the bean's identity, and setting it up in the database table.  
As far as I can tell, all this, including 'whats the ID', must be done 
before ejbPostCreate, which exists primarily for CMR Stuff (I could be 
wrong here - please correct me if I am).

This methodology works fine, basically developing on the assumption 
that the EJB creation classes will setup ejbCreate to be a Query Method 
with the Server Specific "Fetch generated Identity" code, and simply 
notifying the CMPOperationFactory that it needs to call 
AutoGeneratedPKCreateMethod in this case.  A set of classes would 
ideally be generated with the cmp-rdbms xml parser to do this job.  
I've hardcoded CMPOperationFactory at the moment, due to a failure to 
find an effective way of notifying the Operation Factory that it needs 
to handle this as a DB generated Primary Key.

Obviously, UnknownPK detection can be done by looking at return Type.  
What I need now is a methodology for notifying the CMPOperationFactory 
that it needs to use the AutoGeneratedPKCreateMethod.  I'm not sure 
what to do - whether I should put a boolean or some kind of indicator 
in one of the contexts or container classes; I'm looking for feedback 
on this.

At the moment, I'm having some separate issues with findByPrimaryKey 
related to the Transaction policy which I'm looking into, but as I said 
- inserting into the database and then fetching and assigning the 
identity back to the bean works perfectly.   I'm waiting on feedback 
about how to make this 'arrangement' more permanent before I proceed.

I'm thinking in the interim while we work out the questions, and while 
I'm straightening out these other issues I might like to also take a 
stab at some prototype classes to define the CMP / Database 
relationship in XML and automatically setup some of the code, which is 
done manually now in for example BasicCMPEntityContainerTest.setup  ... 
Anyone have any feedback or objections to this?

- Brendan

View raw message