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.  [ 3 posts ] 
Author Message
 Post subject: Strange updates
PostPosted: Fri Jun 13, 2008 5:47 am 
Beginner
Beginner

Joined: Thu Oct 25, 2007 3:45 am
Posts: 22
Hi,

I get very strange updates when I use the Criterial instance List() method.


Here is my code:

ICriteria criteria = session.CreateCriteria(typeof(T));
IList list = criteria.List();


It updates objects of type T, which are loaded before and changed by the application. I need them to be reloaded, not updated.


I have made a session before and I haven't closed it (I need it for lazy collections loading). If I close the session and open a new one - it is ok, but what should I do in this case?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 7:47 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Hibernate flushes the session before executing your criteria. Since you have modified instances of this type in your session, I would say hibernate even has to do so, otherwise you would end up with an inconsistent result.
If you want the modified objects to be reloaded, you can call session.Refresh(obj) on these objects or you can try and set session.FlushMode = FlushMode.Never (or FlushMode.Commit) to prevent the flush.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 8:09 am 
Beginner
Beginner

Joined: Thu Oct 25, 2007 3:45 am
Posts: 22
Thank you for the quick and helpful answer :).


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