I'm having the following code inside one of my services:
@Override
@Transactional
@RetryConcurrentOperation(exception = Exception.class, retries = 12)
public void test() {
Player player = this.playerRepository.findPlayerById(1L);
player.setFirstName("SomeName");
}
the retry mechanism i'm using is the one that was described here: http://josiahgore.blogspot.co.il/2011/02/using-spring-aop-to-retry-failed.html
problem is when i get an optimistic retry (2nd retry) i get an exception:
Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [xxx]
Interesting this is that the mechanism works when i'm removing the transactional annotation and within the non transactional function i'm calling a different transactional method:
// THIS WORKS:
@Override
@RetryConcurrentOperation(exception = Exception.class, retries = 12)
public void test() {
execute();
}
@Override
@Transactional
public void execute() {
Player player = this.playerRepository.findPlayerById(1L);
player.setFirstName("SomeName");
}
Any ideas why this aspect retry mechanism is not succeeding when it's being invoked from a transactional function?