Hi,
I am new to EJB and I've just encoutered to a small problem when implementing an entity EJB. The EJB is mapped to a table which primary key is auto incremented.
In my ejbCreate method I put an primary key, but the real key stored in db is different.
The problem is that I set the primary key property of the bean to the wrong id. The only prossible way seems to make a SQL query just after SQL insert to obtain the real primary key.
But this kind of way seems to me to be a hack.
Is there another way (nice) how to do it? (a container setting or something like it?).
Thanks.
-
EJB primary key problem when using BMP (3 messages)
- Posted by: Marek Fukala
- Posted on: January 24 2002 04:59 EST
Threaded Messages (3)
- EJB primary key problem when using BMP by Michael Gendelman on January 24 2002 12:57 EST
- EJB primary key problem when using BMP by Marek Fukala on January 25 2002 02:52 EST
- EJB primary key problem when using BMP by David Clarke on January 25 2002 04:26 EST
- EJB primary key problem when using BMP by Marek Fukala on January 25 2002 02:52 EST
-
EJB primary key problem when using BMP[ Go to top ]
- Posted by: Michael Gendelman
- Posted on: January 24 2002 12:57 EST
- in response to Marek Fukala
Which database and application server are you using? -
EJB primary key problem when using BMP[ Go to top ]
- Posted by: Marek Fukala
- Posted on: January 25 2002 02:52 EST
- in response to Michael Gendelman
I use MySQL 3.23-46nt and JBoss 2.4.4 .
-
EJB primary key problem when using BMP[ Go to top ]
- Posted by: David Clarke
- Posted on: January 25 2002 04:26 EST
- in response to Marek Fukala
There is nothing to stop a table having multiple primary keys. If you want, you can simply ignore the autoincrementing field and use the key that you set up yourself (provided that it is a persistent primary key). Set up your finder methods to use that key exclusively.