hibernate not throwing stale state exception nor it is overwriting data
- by Reddy
Our application do the following.
1. Start the transaction.
2. Execute a query using prepared statement
3. Check a condition to see the number of rows updated are equal to the required number.
4. It commits on success of above condition otherwise it will roll back
However the problem is that when two threads are simultaneously enter this code. Thread-1 is updating a row in step 2.
It checked the condition and committed successfully since the condition is successful.
Thread-2 started execution somewhere between steps 1 & 4, and it is failing on at condition checking at step 3 (as it is getting number of updated rows as 0).
I expected second thread to throw an exception but it is not. What could be the problem?