title: Hibernate listeners + transaction info
body: <p>In my Spring Boot Data/JPA/Hibernate project I have configured following CREATE, UPDATE and DELETE listeners:</p>
  
  <pre><code>@Component
  public class HibernateListenersConfigurer {
  
      @Autowired
      private EntityManagerFactory entityManagerFactory;
  
      @Autowired
      private HibernateEntityListener listener;
  
      @PostConstruct
      public void registerListeners() {
          final HibernateEntityManagerFactory hibernateEntityManagerFactory = (HibernateEntityManagerFactory) this.entityManagerFactory;
          final SessionFactoryImpl sessionFactoryImpl = (SessionFactoryImpl) hibernateEntityManagerFactory.getSessionFactory();
          final EventListenerRegistry registry = sessionFactoryImpl.getServiceRegistry().getService(EventListenerRegistry.class);
  
          registry.getEventListenerGroup(EventType.POST_COMMIT_INSERT).appendListener(listener);
          registry.getEventListenerGroup(EventType.POST_COMMIT_UPDATE).appendListener(listener);
          registry.getEventListenerGroup(EventType.POST_DELETE).appendListener(listener);
      }
  
  }
  
  
  @Component
  public class HibernateEntityListener implements PostCommitInsertEventListener, PostCommitUpdateEventListener, PostCommitDeleteEventListener {
  
      @Override
      public boolean requiresPostCommitHanding(EntityPersister persister) {
          return true;
      }
  
      @Override
      public void onPostInsert(PostInsertEvent event) {
          //get transaction information(like ID) here
      }
  
  ...
  
  }
  </code></pre>
  
  <p>In my listener methods like <code>onPostInsert</code>, <code>onPostUpdate</code> etc I need to get transaction information(like transaction ID). </p>
  
  <p>How to do it ?</p>