title: Transaction inside` TransactionSynchronizationManager` afterCommit with TaskExecutor
body: <p>I have a code using <code>TransactionSynchronization.afterCommit</code> through <code>TransactionSynchronizationManager.registerSynchronization(...)</code> inside a transaction:</p>
  
  <pre><code>TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
    @Override
    public void afterCommit() {
      Manager.save(param)
    }
  });
  </code></pre>
  
  <p>In afterCommit code is called a method with <code>@Transactional</code>:</p>
  
  <pre><code>public class ManagerImpl implements Manager {
    @Transactional
    public void save(...) { ... }
  }
  </code></pre>
  
  <p>I use Spring, Hibernate and EntityManagerFactory, this code runs well when it's running inside Spring MVC, otherwise, when comes a web request but when runs inside a TaskExecutor (<code>org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor</code>) I get the error:</p>
  
  <pre><code>javax.persistence.TransactionRequiredException: no transaction is in progress
  at org.hibernate.jpa.spi.AbstractEntityManagerImpl.checkTransactionNeeded(AbstractEntityManagerImpl.java:1171)
  at org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1332)
  at sun.reflect.GeneratedMethodAccessor2083.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:293)
  at com.sun.proxy.$Proxy147.flush(Unknown Source)
  //called entityManager.flush()
  </code></pre>
  
  <p>I checked the transaction using <code>TransactionSynchronizationManager.isActualTransactionActive()</code> and it returns true.</p>