-->
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: Flush and transactions
PostPosted: Sat Apr 03, 2004 3:31 pm 
Newbie

Joined: Thu Mar 18, 2004 12:29 pm
Posts: 9
Is it necessary to flush the session before committing a transaction?


Top
 Profile  
 
 Post subject: No Need to Flush before Committing...
PostPosted: Sat Apr 03, 2004 4:05 pm 
Beginner
Beginner

Joined: Fri Apr 02, 2004 3:34 am
Posts: 40
Per the reference doc, it does not look like it...


Top
 Profile  
 
 Post subject: Re: Flush and transactions
PostPosted: Sat Apr 03, 2004 4:56 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
MikeC wrote:
Is it necessary to flush the session before committing a transaction?


Not needed - Hibernate will do it automatically. And although it doesn't harm to session.flush() before tx.commit(), I wouldn't recommend it for performance reason - flushing the session takes a time proprotional to the amount of elements loaded in the session...

Still, be aware that if your session flush mode is set to NEVER - tx.commit() will NOT flush it. In this mode, *you* are responsible to flush the session yourself...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 5:58 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Even though documentation does say that hibernate does flush out session persistent objects at regular intervals, I personally prefer to call flush() before every commit(). Just a habit from the JDBC days.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 6:02 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
gpani wrote:
Even though documentation does say that hibernate does flush out session persistent objects at regular intervals, I personally prefer to call flush() before every commit(). Just a habit from the JDBC days.


From the code:
Code:
      if ( session.getFlushMode()!=FlushMode.NEVER ) session.flush();
      try {
         session.connection().commit();
         committed = true;


So flush before commit is not needed ;)

(same kind of code for JTATransaction)


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.