We have a DB that uses triggers to generate the next sequence when the
record is placed. I am going to try to put a call to
Context.getPrimaryKey() in the ejbPostCreate method. When I looked at the
XML descriptors on the iPlanet this method should work. I'm not sure
about jBoss or WebSphere( which I'm testing now).
Jonathan Bricker
Lilly Research Labs
Java ATG
Ole Husgaard <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
01/17/01 05:56 PM
Please respond to jBoss
To: jBoss <[EMAIL PROTECTED]>
cc:
Subject: Re: [jBoss-User] Entity CMP
Luke Taylor wrote:
> Isn't it rather risky using MAX to obtain the next primary key, as
> there could be multiple threads creating new entities, and two or more
> of them could obtain the same value for MAX and attempt to use the same
> primary key?
If done outside a transaction, you could risk
the above scenario. But if the "SELECT MAX(...) ..."
and the "CREATE ..." is done in the same transaction,
the transaction isolation ensures that this cannot
happen.
> The best way I'm aware of is to use a DB sequence, but
> this involves proprietary SQL.
Yes, sequences are better, but not all databases support
them.
Best Regards,
Ole Husgaard.
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]