Hi,
I have a problem with NullPointerExceptions when
calling ejbCreate() on a Bean, which has a
corresponding table with a AUTO_INCREMENT primary key.
I searched the archive, and found the suggestion
from Joe Gittings <[EMAIL PROTECTED]> ,
but I doubt a little bit, that this will work
correctly for parallel requests.
Let me explain my doubts and correct me, if I'm wrong:
His suggestion is to use a helper class with a method like
public static int getNewAutonumberValue(DataSource ds,String
sTableName,String sFieldName)
In this method, he does a "select max(primarykey_field)",
and that is where I have a problem.
The select max() statement of the second (parallel) request
will return the same value as for the first call, because
it will only be incremented by the Database-Engine through
a completed insert.
I suppose Joe's solution must be extended to do an insert,
get the primary-key value from the new row and then do a delete,
which is really not nice and produces a big overhead for
the performance.
Also, I don't understand, why I get the NullPointerException,
even if I use an ejbCreate() method with no parameters.
Why does Jonas not do an insert with a NULL-Value for
the primary key, if this method is used. Also
when I use an ejbCreate()-Method with the primary key as parameter
and a null value for that primary key, it would be my unserstanding,
that this should be handled by the Container, too.
I hope you understand my problem...
Also I hope, that there is already a more elegant way to handle
all this...
Thanks,
Stephan
--
_________________________________________________________________________
Stephan Bauer, Dipl. Inform. (FH) IT-Freelancer
Siemensstr. 46 Bauer Internetprojects.de
D-94315 Straubing Tel.: +49 9421 9749549
E-Mail: [EMAIL PROTECTED] Fax: +49 9421 9749550
http://www.internetprojects.de Mobil: +49 172 9795002
Software-Design, Implementation & Webhosting
_________________________________________________________________________
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".