-->
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: How to re-read object
PostPosted: Mon Aug 06, 2007 7:02 pm 
Newbie

Joined: Wed Jul 04, 2007 5:31 pm
Posts: 17
What is the best way to do this:

- re-read object from database, including all it's associations and collections
(the reason for this is simply to discard changes made to object)
- object (or any of its associations/collections) should not become detached
(that would happen if you call Evict)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 07, 2007 12:56 am 
Regular
Regular

Joined: Tue Feb 21, 2006 9:50 am
Posts: 107
try ISession.Refresh(object).

Regards
Klaus


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 07, 2007 12:43 pm 
Newbie

Joined: Wed Jul 04, 2007 5:31 pm
Posts: 17
ISession.Refresh(object) doesn't refresh object's associations...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 07, 2007 6:10 pm 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
You could just clear the session and re-execute the load of the object you're after, but it really depends on what you are trying to do...

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 07, 2007 8:07 pm 
Newbie

Joined: Wed Jul 04, 2007 5:31 pm
Posts: 17
Thanks Symon, but Clear is even worth than Evict - it will detach all objects in Session...


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.