pStatement = con.prepareStatement(
"Insert into Attribute " +
"(ID, Value, Display_Format, Attribute_Switches, Name, Type_ID)
" +
"Select max(id)+1, ?, ?, ?, ?, ? from Container ");
Wouldn't most, if not all, databases handle concurrancy issues in this
case?
[EMAIL PROTECTED] wrote:
How about using some creative SQL like:
pStatement = con.prepareStatement(
"Insert into Attribute " +
"(ID, Value, Display_Format, Attribute_Switches, Name, Type_ID) " +
"Select max(id)+1, ?, ?, ?, ?, ? from Container ");
What about java.rmi.server.UID? It has a hashCode() method that returns an
integer.
-Original Message-
From: Peter Routtier-Wone [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 04, 2001 11:45 AM
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] Writing a finder which returns max id
You can also use the facilities of the database engine to help with this
problem. Oracle has sequences which guarantee a unique number even with
concurrent access. Sybase has autoincrement columns.
Use of the database as a UID dispenser has its merits with respect to the
concurrency issue,
]
Sent: Tuesday, April 03, 2001 7:39 AM
Subject: Re: [JBoss-user] Writing a finder which returns max id used
Wouldn't the easiest solution be to make a select max(key) statement and
then add 1 to get your new key?
This isn't an EJB question, it's a general concurrency issue.
What you say