title: Listening for Hibernate Session creation
body: <p>I have a bug in my code that is causing a hibernate exception where an object is being associated with two open sessions when calling <code>session.lock()</code>.</p>
  
  <p>I am using Spring 3.0.4 with HibernateTemplate and Hibernate 3.6.0.</p>
  
  <p>I would like to be able to trap when a Session is created, create/store a stacktrace for the Session and then proxy the Session so when <code>close()</code> is called the the stacktrace is cleaned up.</p>
  
  <p>I have found <a href="https://stackoverflow.com/questions/3959035/how-to-trace-session-creation">this question</a> but this is specifically for web-apps.  I've poked through the hibernate event/Session factory stats code and spring code but can't see an appropriate hook point.</p>
  
  <p>Does anyone have any suggestions to do this?</p>