-->
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.  [ 5 posts ] 
Author Message
 Post subject: Leaving sessions unclosed in TransactionSynch
PostPosted: Tue Sep 28, 2004 2:06 pm 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:09 am
Posts: 46
Location: Geneva, Switzerland
In TransactionSynch session.close() should be moved from beforeCompletion() to afterCompletion() because beforeCompletion() is not called in case of rollback.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 30, 2004 12:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Thanks for catching that. It is fixed in CVS.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 9:11 am 
Newbie

Joined: Sat Sep 11, 2004 12:28 pm
Posts: 7
Location: Raleigh, NC
I don't mean to thread-hijack, but would this have any relation to why I keep receiving

[TransactionSynch] Session already closed

messages in JBoss 4.0.0? I've never gotten these messages before (with the 3.2.x/hibernate setup) and it doesn't seem to affect the operation, but the fact that the message keeps appearing is a bit concerning.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 2:48 pm 
Beginner
Beginner

Joined: Mon Aug 16, 2004 6:09 am
Posts: 46
Location: Geneva, Switzerland
rammic wrote:
I don't mean to thread-hijack, but would this have any relation to why I keep receiving

[TransactionSynch] Session already closed

messages in JBoss 4.0.0? I've never gotten these messages before (with the 3.2.x/hibernate setup) and it doesn't seem to affect the operation, but the fact that the message keeps appearing is a bit concerning.


Make sure you neither flush nor close session itself (this is intended to be done in TransactionSync on transaction commit, and this is a big advantage of using jboss-hibernate integration stuff).

Code:
   public void beforeCompletion()
   {
      if ( !session.isOpen() )
      {
         log.warn("Session already closed");
      }
      else
      {
         try
         {
            log.trace("Flushing Session");
            session.flush();
         }
         catch(Throwable t)
         {
            log.warn("Error flushing session");
         }
      }
   }



You see in case of closed session you miss managed flush completely.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 06, 2004 9:49 am 
Newbie

Joined: Sat Sep 11, 2004 12:28 pm
Posts: 7
Location: Raleigh, NC
That did it! A bit weird though, cause I could have sworn that I did that before and the changes were not being reflected in the session. It works now though, which is all that matters.

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.