This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Note: The Action, Service & DAO classes are instantiated using Spring 2.5's Dependency Injection technique. We use Struts2.
Problem: 2 concurrent users search for the same record and User1 updates Attribute1 while User2 updates Attribute2. User1 first clicks on 'Save' and then User2 clicks on save (they follow each other with a difference of few seconds). When we see the data in database, only the User1's update is present. The Audit columns also show only the User1's update. The User2's update on Attribute2 is not done , at the sametime, no Exceptions are thrown.
We tried using the begin transaction and commit transaction in iBatis surrounding the invokation of the update query defined in the sqlmap xml. The same issue persists. We also tried removing those transaction commands, yet the problem persists.
Should we do anything special/different to handle concurrency during updates ? Wouldn't ORMs like iBatis handle by themselves ?
Wouldn't the iBatis ORM handle the concurrency when 2 users are trying to concurrently update the same record ? Should we have to be setting the ISOLATION levels or moving such simple DML statements to stored procedures for the sake of concurrency ?
Note: We have also tried using the transaction APIs available in iBatis (as in the below example), but still the concurrency problem persists.
Additional Info: Further investigation revealed the following information.
When User1 & User2 clicks on the a record, it's complete data is fetched for viewing.
Now when both User1 & User2 changes few attributes and click save (concurrently), say first User1's data is updated and then while User2's data is being updated, the already updated data of User1 is over-written & lost.
What approach is usually followed in such screens to handle such scenarios ?
Work like you don't need the money. Love like you've never been hated. Dance like nobody's watching. Sing like nobody's listening. Live like it's Heaven on Earth.
Currently I Reside HereWEBlog