title: SpringBoot 2 transaction propagation NESTED not supported
body: <p>I have a SpringBoot 2 project and i'm using spring data jpa with hibernate with MySQL5.7</p>
  
  <p>I have problems with the following use case: i have a service method that calls another service's method. If second service's method generates a runtime exception, also the first method is marked as rollback and i cannot commit things anymore. I'd like to only rollback second method and still commit something in the first one. </p>
  
  <p>I tried to use propagation.NESTED but nested transaction are not allowed with hibernate (even if jpaTransactionManager supports them and MySQL supports savepoints).</p>
  
  <p>How can i solve this problem? Can i configure nested in some way?</p>
  
  <p>Please remember i need second method to see changes committed by first so i can't mark the second method as propagation.REQUIRES_NEW</p>
  
  <p>Here is come sample code to clarify my problem:</p>
  
  <p>FirstServiceImpl.java</p>
  
  <pre><code>@Service
  public class FirstServiceImpl implements FirstService
  
  @Autowired
  SecondService secondService;
  
  @Autowired
  FirstServiceRepository firstServiceRepository;
  
  @Transactional
  public void firstServiceMethod() {
      //do something
      ...
      FirstEntity firstEntity = firstServiceRepository.findByXXX();
      firstEntity.setStatus(0);
      firstServiceRepository.saveAndFlush(firstEntity);
      ...
      boolean runtimeExceptionHappened = secondService.secondServiceMethod();
      if (runtimeExceptionHappened) {
          firstEntity.setStatus(1);
          firstServiceRepository.save();
      } else {
          firstEntity.setStatus(2);
          firstServiceRepository.save();
      }
  }
  </code></pre>
  
  <p>SecondServiceImpl.java</p>
  
  <pre><code>@Service
  public class SecondServiceImpl implements SecondService
  
  
  @Transactional
  public boolean secondServiceMethod() {
      boolean runtimeExceptionHappened = false;
      try {
      //do something that saves to db but that may throw a runtime exception
      ...
      } catch (Exception ex) {
          runtimeExceptionHappened = true;
      }
      return runtimeExceptionHappened;
  }
  </code></pre>
  
  <p>So the problem is that when secondServiceMethod() raises a runtime exception it rollback its operations (and that's OK) and then set its return variable runtimeExceptionHappened to false, but then firstServiceMethod is marked as rollback only and then</p>
  
  <pre><code>firstEntity.setStatus(1);
  firstServiceRepository.save();
  </code></pre>
  
  <p>isn't committed.</p>
  
  <p>Since i can't use NESTED propagation how can i achieve my goal?</p>