title: Hibernate interceptor and event listeners
body: <p>I wonder if it's possible to find out what hibernate <em>really</em> did to the database (i.e., committed changes). I'd like to notify another process on certain changes.</p>
  
  <p>I guess that the <a href="https://docs.jboss.org/hibernate/orm/5.0/javadocs/org/hibernate/event/spi/EventType.html">EventType</a>s <code>POST_COMMIT_DELETE</code>, <code>POST_COMMIT_UPDATE</code> and <code>POST_COMMIT_INSERT</code> should do, but given exactly zero documentation, it's only a guess. Can someone confirm? Am I missing any?</p>
  
  <p>I'm also unsure about how to obtain what gets really written. The <code>PostInsertEvent</code> contains both <code>Object entity</code> and <code>Object[] state</code>, which of the two should I trust?</p>
  
  <hr>
  
  <p>A side question: I'm using no XML, no Spring, no JPA, just <code>Configuration</code> and <code>buildSessionFactory</code>. Is this really the way listeners should be registered?</p>
  
  <pre><code> EventListenerRegistry registry = ((SessionFactoryImpl) sessionFactory)
      .getServiceRegistry()
      .getService(EventListenerRegistry.class);
  registry.appendListeners(....);
  </code></pre>
  
  <p>I'm asking as its 1. dependent on an implementation detail, 2 totally ugly, 3. nearly perfectly undiscoverable.</p>