-->
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.  [ 8 posts ] 
Author Message
 Post subject: the concept of the flush....
PostPosted: Tue Mar 16, 2004 11:41 am 
Regular
Regular

Joined: Tue Dec 30, 2003 2:35 am
Posts: 85
when hibernate run session.flush,wait happen to the database.
does the viewpoint
<-- when hibernate run session.flush ,hibernate send sql to the database -->
is right?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 16, 2004 12:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
yes


Top
 Profile  
 
 Post subject: i mean that....
PostPosted: Tue Mar 16, 2004 12:12 pm 
Regular
Regular

Joined: Tue Dec 30, 2003 2:35 am
Posts: 85
when hibernate run session.flush ,hibernate send sql to the database

but i can't image
if in one transaction,what is different between run flush and not run flush?(because all sql is taken effect after hibernate commit the transaction)

if all this viewpoint i think is right,so i can't understand the meaning of run the flush in the middle of transaction?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 16, 2004 12:14 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
it can help you debug :)


Top
 Profile  
 
 Post subject: but.... the total usage of the flush only
PostPosted: Tue Mar 16, 2004 8:01 pm 
Regular
Regular

Joined: Tue Dec 30, 2003 2:35 am
Posts: 85
but.... the total usage of the flush is only to help me to debug the code ????
really?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 16, 2004 8:04 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read the reference documentation, the section about "Flushing". Hibernate flushes the state of the in-memory objects to the database to ensure integrity and prevent stale data. If you modify an object and then execute a find(), you expect the find() to return the changes.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 17, 2004 3:07 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
i think what linuxaid wanted to ask is why calling "explicitly" flush() knowing it is called at commit, before find...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 17, 2004 4:27 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
delpouve wrote:
it can help you debug :)

Not only for debug, in CMT environment, if you don't use tx.commit(), you have to call session.flush() manually before each session.close(). It confuses a bit.

http://forum.hibernate.org/viewtopic.php?t=928427&postdays=0&postorder=asc&start=15
michael wrote:
You can do the following:

open session
* do stuff
session.flush()
session.close()

or

open session
tx = session.beginTransaction()
* do stuff
tx.commit()
session.close()

Both will provide identical results in a CMT environment, except the second one is also easier portable to a non-CMT environment.


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