title: Spring @Transactional does not work when I call a method inside of it. How can I slove it?
body: <p>I have an entity with 3 field (id, name and age). I have created a repository (PersonRepository) in which I want to see how Transaction works.
  I find strange that if I insert a method call inside a method, this does not work as expected.</p>
  <pre><code>public void nestedTransaction() {
          personRepository.save(new Person(11L, &quot;A1&quot;, 26));
          childTransaction();
  }
  
  @Transactional(propagation = Propagation.REQUIRED)
  public void childTransaction() {
      personRepository.save(new Person(10L, &quot;A2&quot;, 26));
      throw new RuntimeException(&quot;ExceptionTest child&quot;);
  }
  </code></pre>
  <p>After the autowiring of PersonRepository that contain the above methods, I call:</p>
  <pre><code>try {
      serviceTransaction.nestedTransaction();
  } catch (Exception e) {
      System.out.println(&quot;Exception: &quot;+e.getMessage());
  }
  </code></pre>
  <p>Please do not pay attention on the fact that I'm using System.out.println instead of logging, this is just a test for understanding @Transactional. However, I expect that in my DB there is the entity (11L, &quot;A1&quot;, 26) but not the entity (10L, &quot;A2&quot;, 26)) instead I have both. Why this happen?</p>
  <p>I already know that I can use transactionTemplate and it works using it. For example:</p>
  <pre><code>public void nestedTransaction() {
      transactionTemplate.setTimeout(1000);
      transactionTemplate.setIsolationLevel(TransactionDefinition.ISOLATION_REPEATABLE_READ);
      transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
      personRepository.save(new Person(11L, &quot;Ale2&quot;, 26));
      transactionTemplate.execute(new TransactionCallbackWithoutResult() {
              
         @Override
         protected void doInTransactionWithoutResult(TransactionStatus status) {
              childTransaction();
         }
      });
  }
  </code></pre>
  <p>Can anyone explain this behaviour and how to solve it?</p>