title: Hibernate, listen or override to opneSession from a sessionFactory.openSession()
body: <p>The thing is that if you use</p>
  <pre><code>properties.put(Environment.CURRENT_SESSION_CONTEXT_CLASS, &quot;thread&quot;);
  </code></pre>
  <p>Then Hibernate will put only <code>sessionFactory.getCurrentSession()</code> calls on <code>threadlocal</code> and not <code>sessionFactory.openSession()</code> calls.</p>
  <p><code>getCurrentSession</code> gets delegated to the <code>CurrentSessionContext</code> but <code>openSession</code> do not and they do not register either.</p>
  <p>This is problematic if someone is attempting to register those as well. We want to use a <code>ThreadLocal</code> <code>List</code> where <code>getCurrentSession</code> will use the last on stack.</p>
  <p>The current implementation seems to think that there is no need to manage also openSession calls, since they could not forsee some other potential use ( more correct use ).</p>
  <p>So, am i left with overriding the entity <code>SessionFactoryImpl</code> class to hook in, or is there some <strong>event that is triggered and I can hook into when a Session opens</strong>?</p>