-->
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.  [ 10 posts ] 
Author Message
 Post subject: why flush before commit?
PostPosted: Wed Nov 23, 2005 8:30 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
Look the documentation for flush:

void org.hibernate.Session.flush()
Force the Session to flush. Must be called at the end of a unit of work, before commiting the transaction and closing the session (Transaction.commit() calls this method). Flushing is the process of synchronising the underlying persistent store with persistable state held in memory.

Why should I call the flush before commit the transaction? Is there any problem with this:

Transaction t = session.beginTransaction();
session.saveOrUpdate(object);
t.commit();
session.flush()

?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 23, 2005 8:41 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
no problem, but flush after commit do nothing

flush send command to database and commit do it explicit


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 23, 2005 9:51 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
So, if you flush after the commit, the database won't be updated?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 23, 2005 11:25 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
you may want to read parts of this ... http://forum.hibernate.org/viewtopic.php?t=950347


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 7:04 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Quote:
So, if you flush after the commit, the database won't be updated?


no, you needn't flush after commit - it do nothing
commit flush explicit and update and commit changes to database


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 8:57 am 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
I'm using FlushMode.NEVER.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 9:19 am 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
What the answer for my first question considering the FlushMode.NEVER ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 12:27 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
you will have read only session.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 3:05 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
In this case, is there some difference calling the flush before or after the commit ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 3:08 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
No.


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