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 ");

pStatement.setString(1, value);
pStatement.setString(1, displayFormat);
pStatement.setLong  (2, attributeSwitches);
pStatement.setString(1, name);
pStatement.setInt   (2, typeID);

if (pStatement.executeUpdate() != 1)
{
     throw new CreateException(...
}

Just fill in the parameters with your values and the SQL statement is executed
all at once.
Wouldn't most, if not all, databases handle concurrancy issues in this case?

Regards,
Tim Haley



_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to