-->
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.  [ 6 posts ] 
Author Message
 Post subject: session.find result in flush
PostPosted: Mon Jul 10, 2006 3:57 am 
Beginner
Beginner

Joined: Tue Feb 15, 2005 8:14 am
Posts: 32
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.1.8

Mapping documents:

I have read that certain session.find results in a flush !!!

Is there any doc that says which find result in a flush ?

Kris


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 7:51 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Well, no. find() should not issue a flush()... But you have to give more details if you want us to help you (exceptions, the code you write...).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 11, 2006 9:01 am 
Beginner
Beginner

Joined: Tue Feb 15, 2005 8:14 am
Posts: 32
In the book "Hibernate A J2EE Developer's guide" ISBN : 0-321-26819-9 it is written that Certain session.find() or session.iterate() will cause a flush to occur automatically.

I dont get any exception, but I can se that the onFlushDirty in the Interceptor is called the executing this line :

List l = session.find("select from Authority as au where au.code=? and au.type.sid=? and au.type.cid=?", new Object[] { code, type.getSid(), type.getCid() }, new Type[] {
Hibernate.STRING, Hibernate.STRING, Hibernate.STRING });


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 11, 2006 11:31 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
In fact, after thinking a bit more, yes. More precisely, in the refdoc, it is stated that the flush could occur sometimes, but you can't control it.

Actually, I can't see why this could be a problem for you ? Do you just want to understand why or is this causing problems ?

If it's the understanding you're interested in. Maybe the flush() occurs because a timeout was elapsed, saying that it would be a good idea to synchronize the session state with the db.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 11, 2006 12:14 pm 
Newbie

Joined: Mon Jul 03, 2006 5:16 am
Posts: 5
I think the flush occurs because in a find operation usually a "select" query is performed, and if hibernate doesn't flush pending operations, current query cannot access to modified values. Timeout is not responsible of flushing.

Example:

Code:
session.save(myObject);
List list = session.find("FROM MyObject");
//previous object is not retrieved if hibernate doesn't flush


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 11, 2006 12:33 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
titoose wrote:
I think the flush occurs because in a find operation usually a "select" query is performed, and if hibernate doesn't flush pending operations, current query cannot access to modified values. Timeout is not responsible of flushing.

Example:

Code:
session.save(myObject);
List list = session.find("FROM MyObject");
//previous object is not retrieved if hibernate doesn't flush


Yes, I think you're obviously right. In fact, for example, if not flushing before retrieving instances by find() some triggers could have been not "triggered" and so data would not be up to date at the return of the find().

Very interesting to think about indeed. You helped me to a better understanding of this, I guess, thanks. Maybe some expert could confirm what I suppose, but it seems logical enough, isn't it ?

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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