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.
- in pom.xml, add the db-util dependency
- Configure the
- Mark the method that is prone to throw
@Retry(times = 10, on = OptimisticLockException.class)