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.
Both open two different sessions at the same time and load the same table row in memory.
If User1 and User2 both update some columns of that row and suppose User1 commits the transaction first.
What will happen when User2 commits the transaction. Will his changes be overwritten over User1's changes in the database table?
The Version attribute can also be helpful in performing optimistic locking:
"Hibernate uses the updated row count to detect conflicting data modifications. Hibernate will automatically disable JDBC batch updates if you are using versioned data, since some JDBC drivers return incorrect values after UPDATEs "