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.  [ 2 posts ] 
Author Message
 Post subject: Session.Refresh() - what exactly it does?
PostPosted: Thu Mar 08, 2007 5:27 pm 
Newbie

Joined: Thu Mar 08, 2007 5:14 pm
Posts: 6
NHibernate version:1.0.2

Hello,

I have a question about session.refresh() function. Assume we have a graph of objects in memory:
1. On top there is object A, which has set of objects B and each object B has set of object C.
2. We load object A (set of objects B is lazy initialize). Then we initialize this set and, as it's not too large, we initialize also set of objects C in each object B.
3. This creates us a graph of objects.

Session is opened before each operation and closed just after it is finished.

My question is: if I'll call session.refresh() on object A - will graph remains consistent? Or object A will be replaced and references between object will be lost?

In "Java persistence with Hibernate" we can find:
Code:
Before you add refresh() calls to your application, we have to tell you that the
primary goal of the previous section was to show you when to use refresh().
Many Hibernate beginners don’t understand its real purpose and often use it
incorrectly. A more formal definition of refresh() is “refresh an in-memory
instance in persistent state with the current values present in the database.”


So I suppose that only values will be restored if needed and graph of object will remain unchanged - am I right?

Best regards,
tytus

Best regards,
tytus


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 09, 2007 1:54 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
In Hibernate 3 it is possible to configure cascading so that associated objects are refreshed along with the original entity. In NHibernate it's not possible, so associated objects will not be refreshed.


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