-->
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.  [ 3 posts ] 
Author Message
 Post subject: cascade: save-update
PostPosted: Fri Sep 02, 2005 12:11 am 
Regular
Regular

Joined: Mon May 30, 2005 11:20 pm
Posts: 66
Hi, I can understand setting cascade="delete" or cascade="none" on a one-many or many-one relationship.

With cascade="delete" on parent's mapping file, children gets deleted when parent is deleted.

With cascade="none" on parent's mapping file, nothing is done - children remains as orphan.

But, what's meant by:

cascade: "save-update" ...

there's nothing on children to be "updated" when parent's updated? The only thing to be updated is FK/PK field (foreign/primary key).

Thanks.


Top
 Profile  
 
 Post subject: from the book
PostPosted: Fri Sep 02, 2005 1:43 am 
Newbie

Joined: Fri Sep 02, 2005 1:11 am
Posts: 4
Well, someone please correct me if i'm wrong but what I understand this to mean is:

(assume i already have a parent object that was loaded from Hibernate)

Child child = new Child();

parent.Children.Add(child);
child.Parent = parent;

if the Parent defines it's children 'set' with cascade="save-update", then the child object will be automatically persisted to the database at the next commit.

if save-update is not specified, then (if I am reading the docs correctly) you would have to explicitly call save on the child object in order to persist it to the database.


Top
 Profile  
 
 Post subject: crystal clear, thanks.
PostPosted: Fri Sep 02, 2005 2:44 am 
Regular
Regular

Joined: Mon May 30, 2005 11:20 pm
Posts: 66
crystal clear. Thanks


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