title: Spring Data: rollback transaction on retry
body: <p>There is an entity:</p>
  
  <pre><code>@Entity
  class A {
      ...
      @Version
      int version; 
  }
  </code></pre>
  
  <p><code>A</code> instances update implemented in optimistic manner:</p>
  
  <pre><code>@Transactional(rollbackFor = {StaleStateException.class})
  @Retryable(value = {StaleStateException.class})
  public void updateA() {
      A a = findA();
      B b = new B();
      // Update "a" somehow
      a.update();
      // "b" is saved on each retry!
      save(b);
  }
  </code></pre>
  
  <p>As stated in comments, seems that transaction is not rollbacked when <code>StaleStateException</code> occurs, so <code>B</code> instance is saved on each retry.</p>
  
  <p>Is it possible to rollback transaction on retry? </p>
  
  <p>The desired behaviour is that <code>b</code> is saved only on successfull <code>a</code> update.</p>