-->
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: isModified() flag/tag in Hibernate
PostPosted: Mon Nov 24, 2003 5:48 am 
Newbie

Joined: Mon Nov 24, 2003 5:34 am
Posts: 2
I have some queries about Hibernate:

a) if I have a 4 level deep Class Hierarchy and want to update a member at the bottom level I could set up a cascade="all-delete-orphan" at various levels and issue an update of the instance at the top of the hierarchy. Or could I just do a simple update on the instance at the bottom of the hierarchy explicitly ? The pdf doco (P. 52) recommends doing an update at the top (the dependent is a LifeCycle object). However this sounds inefficient since won't Hibernate have to navigate through the various objects in the Obejct Graph ?

b) P. 53 of the doco says that "Furthermore a mere reference to a child from a persistent parent will result in a save / update of the child". So if I read some children it will perform updates ?

c) Is there any concept of a isModified() tag like in WebLogic where the update will only occur if something has changed on the instance ? In our previous architecture we implemented something like that and let our persistence mechanism detect changes via the tag and perform the required update. Hibernate sounds more along the lines of getting the business logic to explicitly perform the update explicitl


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2003 6:31 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
If you load an object from a session A, the object will be updated when flushing the session A (wether you saveOrUpdate it or not).

If you indirectly load an object
Code:
A a = (A)session.load(A.class, id);
C c = a.getB().getC()


it will be updated whan flushing session.

It you linked a transient object with another one (parent and cascaded) :
* if the parent is transient, save the parent and the child will be saved
* if the parent is persistent, the the child will be saved because of cascade.

You don't have to load the whole association tree.
Let's have A -> B -> C -> D

If I want to update D,
session.load(D);
//change D
//session.flush();

If I want to change D from a C
session.load(C)
c.setD(new D());
session.flush();

No need to load A.

Hope this help

_________________
Emmanuel


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.