Skip to content

Demostration of Optimistic and Pessimistic Locking

Notifications You must be signed in to change notification settings

sks1995/sql-locking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Demostration of Optimistic and Pessimistic Locking

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages