Hi,
 
I've written a simple Entity Bean with CMP which has a primary key of type int.
In the database (Oracle), I have set a trigger to auto-increment the primary key attribute mapping the primary key field of the CMP Bean, each time a row is created in the table.
When calling the ejbCreate method I get an exception :
 
javax.ejb.EJBException: Failed to load bean from database
javax.ejb.EJBException
java.rmi.RemoteException: Got exception in activate:; nested exception is:
        javax.ejb.EJBException
 null EJBContext in RequestCtx!
 System Exception raised by request:
java.rmi.RemoteException: Got exception in activate:; nested exception is:
        javax.ejb.EJBException
 System Exception in business method:java.rmi.RemoteException: Got exception in activate:; nested exception is:
        javax.ejb.EJBException
I have searched on the mailing list some solutions to get the primary key to increment automatically, but all of them are quite not suitable :
- the solution of doing a "SELECT(MAX)" on the primary key, proposed by Joe on page http://www.objectweb.org/messages/JonasUsers/2000/03/msg00020.html, is not reliable due to parallel acces to the database, and wouldn't match the CMP favour wich is not to include JDBC in the java code.
- the solution of Guillaume (http://www.objectweb.org/messages/JonasUsers/2000/04/msg00085.html) which is to implement 2 EJB is a pretty heavy one and also needs some BMP to be written.
 
So here is my question (which maybe you already have guessed) : Is there a way for the primary key of an Entity Bean with CMP to be auto-incremented without writting some JDBC code ?
 
I couldn't find a real answer on the JOnAS mailing list and I would simply like to know if it's possible or not (and of course, if it's possible, the way to do it). It seems I'm not the only one having this problem, so I think it should be sayed once for all at least one time on the mailing list or the FAQ...
 
Thanks
 
                                Thomas

Reply via email to