title: Adding listener to hibernate session
body: <p>I recently came across a situation where I have to do some actions when object is updated through <strong>Hibernate session</strong>, but hibernate session does not have any methods where I can add update listener. To summarize my intent I am posting a sample program.</p>
  
  <pre><code>public class SessionListenerTest{
  
      public static void main(String[] args){
  
              ...     
  
          Session session = sessionFactory.openSession();
  
          session.addSessionListener(new SessionListener(){
  
              onUpdate(Object dbObject){
                  ...
              }
  
              onDelete(Object dbObject){
                  ...
              }
  
              onInsert(Object dbObject){
                  ...
              }
          });
      }
  }
  </code></pre>
  
  <p>Whenever ant object is updated through hibernate session, <strong>onUpdate</strong> should be called and so on. But Hibernate session does not have any methods similar to <strong>addSessionListener</strong>. Any help is appreciated..</p>