Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src/main
README.md
Retry Optimisti Lock.png
pom.xml

README.md

  1. How To Retry Transactions After OptimisticLockException Shaped Via @Version

Note: Optimistic locking via @Version works for detached entities as well.

Description: This is a Spring Boot application that simulates a scenario that leads to an OptimisticLockException. When such exception occur, the application retry the corresponding transaction via db-util library developed by Vlad Mihalcea.

Key points:
- in pom.xml, add the db-util dependency
- Configure the OptimisticConcurrencyControlAspect bean
- Mark the method that is prone to throw OptimisticLockException with @Retry(times = 10, on = OptimisticLockException.class)

Output sample:


You may like to try as well:

You can’t perform that action at this time.