title: Spring data - Optimistic retry mechanism not working properly
body: <p>I'm having the following code inside one of my services:</p>
  
  <pre><code>@Override
  @Transactional
  @RetryConcurrentOperation(exception = Exception.class, retries = 12)
  public void test() {
  
  Player player = this.playerRepository.findPlayerById(1L);
  player.setFirstName("SomeName");
  }
  </code></pre>
  
  <p>the retry mechanism i'm using is the one that was described here:
  <a href="http://josiahgore.blogspot.co.il/2011/02/using-spring-aop-to-retry-failed.html" rel="nofollow">http://josiahgore.blogspot.co.il/2011/02/using-spring-aop-to-retry-failed.html</a></p>
  
  <p>problem is when i get an optimistic retry (2nd retry) i get an exception:</p>
  
  <pre><code>Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [xxx]
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>// 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");
  }
  </code></pre>
  
  <p>Any ideas why this aspect retry mechanism is not succeeding when it's being invoked from a transactional function?</p>