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: How to reload data
PostPosted: Sat Sep 13, 2008 4:21 pm 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Hello,

I would like to reload data for an entity that have already been loaded with a cirteria and a method List<>() (the data have changed on the database side since they have been loaded the first time). What should I write for this ?

Regards,

mathmax


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 8:11 am 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Nobody knows how to force data to be reloaded inside a session ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 3:15 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Try session.Refresh(obj). But that only works on objects, not on lists that you have retrieved with a query/criteria.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 7:35 am 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
So there is no way to refresh a list ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 8:05 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Besides looping through the list and refresh each object, I don't know of a better way.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 8:06 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
To make it clear, I'm talking about a list in this context:

query.List() or criteria.List()

Mapped collections will be refresh if you refresh the parent.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 8:15 am 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Quote:
Besides looping through the list and refresh each object, I don't know of a better way.


Yes but there can be rows added or removed on the database compared with the list objects.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 8:17 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Can't you just re-run the query/criteria ?

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 10:29 am 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Yes but How to re-run it ? It is the List<>() method that run it, isn't it ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 10:49 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
YOu can build the criteria initially as DetachedCriteria and then attach it to session whenever you have to (rel-)load the date.

_________________
--Wolfgang


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.