Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cfo2K4u4rF18QsPXPFnytf
7 lines
706 B
Plaintext
7 lines
706 B
Plaintext
both sessions read balance=100 version=0
|
|
session A commits +50 -> version is now 1
|
|
session B commits +25 -> jakarta.persistence.OptimisticLockException: Unexpected row count (expected row count 1 but was 0) [update Account set balance=?,owner=?,version=? where id=? and version=?] for entity [lab.hibernate.model.Account with id '1']
|
|
cause: org.hibernate.StaleObjectStateException: Unexpected row count (expected row count 1 but was 0) [update Account set balance=?,owner=?,version=? where id=? and version=?] for entity [lab.hibernate.model.Account with id '1']
|
|
SQL> update Account set balance=?,owner=?,version=? where id=? and version=?
|
|
final balance: 150 (B's stale write was rejected, A's +50 kept)
|