OptimisticOfflineLockConcept http://martinfowler.com/eaaCatalog/optimisticOfflineLock.html
freeMoney
I get the account object for an account number. It has balance of X.
You get the account object for an account number. It has balance of X.
I change the account object by withdrawing 100 units from it. I reduce balance to X - 100.
You change the account object by withdrawing 100 units from it. I reduce balance to X - 100.
I update the account by setting the balance to X - 100.
I commit.
You update the account by setting the balance to X - 100.
You commit.
In affect 200 units are withdrawn but the balance has been reduced only by 100.
Resolution
updateLock
I get the account object for an account number. It has balance of X.
I get the account object for an account number. It has balance of X.
I change the account object by withdrawing 100 units from it. I reduce balance to X - 100.
You change the account object by withdrawing 100 units from it. I reduce balance to X - 100.
I update the account by setting the balance to X - 100.
I commit.
You try to update the account by setting the balance to X - 100.
Your update doesn't update anything as it used version number in the where clause, which has changed.