You've got lots of good options here: + Use either select for update to ensure it's done transactionally with locking. + Use a stored procedure to both incremement the counter and return the key in just +one database round trip. + (My prefered solution) Use the block key grants pattern to fetch blocks of primary +keys from the DB to slowly doll out to the beans needing keys (and use one of the +previous two options to do that transactionally). You can read about the block +grants pattern in Floyd Marinescu's book. +http://www.theserverside.com/books/EJBDesignPatterns/index.jsp + Use a trigger in the database to create the primary keys and let JDBC 3.0 return the +generated primary key. (Returning autogenerated pk's is new in JDBC 3.0.) + Use a stored procedure to both insert a new row and return the generated primary +key. (This pattern is also in Floyd's book.) + Use the auto primary key generation features of the app server made available by EJB +2.0.
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
