Hello,
The session is opened via Threadlocal as per
http://www.hibernate.org/42.html
Then I'm running a transaction:
Code:
try
{
Session session = HibernateSession.currentSession();
tx = session.beginTransaction();
logger.info("session is connected? " + session.isConnected() + " session is open? " + session.isOpen());
try
{
// doing some stuff
}
catch (Exception e)
{
throw new LayoutManagerException(e, me);
}
logger.info("session is connected? " + session.isConnected() + " session is open? " + session.isOpen());
tx.commit();
HibernateSession.closeSession();
}
catch (HibernateException e)
{
throw new LayoutManagerException(e, me);
}
The first logging statement is true/true, while the second is false/false.
This exception is thrown:
Code:
Caused by: net.sf.hibernate.HibernateException: Session is closed
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3288)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.java:109)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:460)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at .LayoutManager.(LayoutManager.java:168)
... 38 more
I'm using Hibernate 2.1.4.
Thanks for any insights.