Quote:
T1 - calls select for update
T2 - call select for update and blocks waiting for the locked row
T1 - reads 0, updates the value to 1 and commits
T2 - reads 0 (this is a stale value, it should read 1), updates the value to 1 (should be 2) and commits
How are the transactions?
it should be
T1 - begin
T1 - calls select for update
T1 - reads 0, updates the value to 1
T1 - commit
It's also possible that you didn't register the transaction manager with the container - using any container/application server?
did you see the chapter about running hibernate in a container in the reference documentation?