-->
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.  [ 7 posts ] 
Author Message
 Post subject: save-update cascade question
PostPosted: Tue Oct 05, 2004 8:33 am 
Regular
Regular

Joined: Thu Aug 28, 2003 10:54 am
Posts: 67
One thing i've always been curious about is why there are no separate cascades fro save and update. I've often thought such a feature very useful. Is this due to some technical concern? Will Hibenrate 3 allow cascading only on inserts and not on updates?

If there is no technical reason for it how simple would it be to modify hibernate to do this and where would I need to look?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 06, 2004 7:49 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The reason is functional, I don't think this would be very useful since it will only work for full insert (no update in the whole graph (ie no existing entity)
or for full update (no new entity in the whole graph).
It seems to me this is very uncommon

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 07, 2004 6:33 am 
Regular
Regular

Joined: Thu Aug 28, 2003 10:54 am
Posts: 67
When you create an object with a collection for the first time it would be usefult to cascade the creation of the children. I often don't use the save-update cascade because an update on the parent forces updates on all the children whether they have been changed or not which is not good if there are a lot of children. But it does simplify the initial insert ( or am I doing something wrong?)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 4:08 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
teknokrat wrote:
I often don't use the save-update cascade because an update on the parent forces updates on all the children whether they have been changed or not [..]. ( or am I doing something wrong?)

This is of course plain wrong.
hibernate does not update children unless they've been changed for real

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 4:12 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
emmanuel,
what's up guy?
teknokrat is right about update on children when a parent is detached and reattach using session.update(parent).

teknokrat,
You can avoid this by using select-for-update option in children mapping file. It isn't sure that it is more efficient but it is usefull to avoid trigger and version update.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 5:40 am 
Regular
Regular

Joined: Thu Aug 28, 2003 10:54 am
Posts: 67
yeah, its the detaching then attaching that triggers the update. I'll check out select for update though currently its not a major issue. Just curious, how will hibernate 3 will deal with different cascade semantics?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 19, 2004 5:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate3 has a number of "operations", each of which may have cascade independently enabled:

save-update
create
merge
delete
evict
lock
replicate
delete-orphan

(and maybe I should add cascade refresh)

you can combine cascade styles, eg:

cascade="create,merge,delete"
cascade="all,delete-orphan"
cascade="create,lock"


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