These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Threadlocal session is lost
PostPosted: Mon Jun 07, 2004 8:00 am 
Beginner
Beginner

Joined: Thu Oct 09, 2003 11:41 am
Posts: 39
Location: Paris, France
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 07, 2004 10:10 am 
Beginner
Beginner

Joined: Thu Oct 09, 2003 11:41 am
Posts: 39
Location: Paris, France
ok, the problem solved.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.