hibernate not throwing stale state exception nor it is overwriting data

Posted by Reddy on Stack Overflow See other posts from Stack Overflow or by Reddy
Published on 2010-06-05T13:01:30Z Indexed on 2010/06/05 13:12 UTC
Read the original article Hit count: 272

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about hibernate