This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Our project is large scale one based on J2EE, we use a ID Bean of type Stateless Session bean to generate the next ID (primary Key).Next ID is generated by reading the next ID from table and immediately updating that table with the new ID.Meaning One select and update statement in nextID() method.(Table has only one row with 2 columns - Sl_No and next_ID.) Settings on this ID bean is TX_REQUIRES_NEW so that the transaction is commmited immediately and leavig way for the next client.
When ever a transaction needs to add a new row to the database, it will call the ID Bean by passing the table name and will get the next ID. Please note that we have only one ID bean for the entire application. It is definitely will affect the response time because this ID bean is used by all the users. In a particular transaction, one user will insert 180 records to the table. We do not go with any Database or EJB specific Primary Key Geneartion method. I would like to know whether this ID generation could be improved in multi user environment or any other better / proven implemenation is availabe in the J2EE world?
I think the problem is you want using stateless Bean to Update your Next ID! That it is not correct, I would use two Beans at your situation, one stateless Bean connect to web and the other one will be Entity Bean Update Database. That can solve your mult-user problem.
Have you tried this Mock Exam Testing Engine yet?<br /><a href="http://www.mycgiserver.com/~nan111/index.html" target="_blank" rel="nofollow">www.mycgiserver.com/~nan111/index.html</a>
The best way to update the table would be to write a trigger in the database instead of using the bean to update it. This is a more lighter and more durable technique and would work wherever u call the table from, be it bean or jdbc. Cheers.. Daman