Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 1.32 KB

README.md

File metadata and controls

17 lines (13 loc) · 1.32 KB

SqlLockingApplication

This is a small project to understand the role of optimistic and pessimistic locking in dealing with highly concurrent systems.

Medium Article Link

It explains the Concurrency Control With Optimistic and Pessimistic Locking

How to setup ?

Run mvn clean install -s settings.xml

Things to look for

  1. PurchaseOrder.java class has the logic for optimistic and pessimistic locking

  2. SqlLockingApplicationTests.java contains all the testcases.

    1. test_failureScenario demonstrates The Lost Update anomaly.
    2. test_OptimisticLockingScenario demonstrates the solution using optimistic locking.
    3. test_PessimisticLockingScenario demonstrates the solution using pessimistic locking.
  3. StockRepository.java has different update statements fired for various locking scenarios.