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
Run mvn clean install -s settings.xml
-
PurchaseOrder.java class has the logic for optimistic and pessimistic locking
-
SqlLockingApplicationTests.java contains all the testcases.
test_failureScenariodemonstrates The Lost Update anomaly.test_OptimisticLockingScenariodemonstrates the solution using optimistic locking.test_PessimisticLockingScenariodemonstrates the solution using pessimistic locking.
-
StockRepository.java has different update statements fired for various locking scenarios.