-->
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.  [ 4 posts ] 
Author Message
 Post subject: Question about cascade settings
PostPosted: Sun Mar 28, 2004 4:27 pm 
Beginner
Beginner

Joined: Tue Mar 16, 2004 5:15 am
Posts: 33
Hi there,

I wonder myself, if I really understood the cascade stuff right. Here is what I belive it is all about:

As an example lets assume we have a category category and children productA and productB.

1. Cascade triggers an update of related elements. It can be specified on parent and/or children side. So a product can specify a cascade setting to be applied everytime the product's state changes in a certain way (depending on the kind of the specified cascade setting).

2. Cascade on parent side: Setting cascade='delete' or 'all' would cause productA and productB to be updated if the parent category gets deleted. The update of the products is similar to productA/B.setParent(null).

3. Cascade *-delete-orphan on the parent side would trigger deleting also all assigned children.

4. Cascade on child-side:
- The category is updated if any product it contains gets modified in a certain way. So when a product is removed, the set of related products of the category is updated (the product is removed from within).
- specifying *-delete-orphan on child-side, when productB is deleted, the category is also deleted, causing productA to be updated/deleted (if specified).

5. Here is what I think, what the cascade settings may express:

delete - similar to 'on delete set null' rule of SQL's foreign key mapping
*-delete-orphan - similar to 'on delete cascade' rule of SQL's foreign key mapping

6. The cascade setting 'all' simply means, cascade settings 'save-update' and 'delete' are applied at the same time.

Please tell me if my assumtions are all correct.


Thanks a lot,

Martin (Kersten)

PS: By the way, what is cascade setting save-update for? When do I use it?


Top
 Profile  
 
 Post subject: Re: Question about cascade settings
PostPosted: Mon Mar 29, 2004 7:23 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Martin Kersten wrote:
2. Cascade on parent side: Setting cascade='delete' or 'all' would cause productA and productB to be updated if the parent category gets deleted.

No, parent deletion will delete child.

Martin Kersten wrote:
3. Cascade *-delete-orphan on the parent side would trigger deleting also all assigned children.

Remove a child from a parent will delete it if it's orphaned.

...

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 29, 2004 8:29 am 
Beginner
Beginner

Joined: Tue Mar 16, 2004 5:15 am
Posts: 33
Well seams, I do not understand the cascading right.

So what does save-update means exactly. So if the category has definied save-update on its mapping does this means the set 'null' on cascade?

So if I have a one to many mapping by assoziation (parent is not aware of beeing referenced), how would I do this? You know it needs to be set null if the referenced size gots deleted. I am totally unsure how to handle such thing.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 31, 2004 9:09 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Cascading and association management are not related.
save-update means if parent is saved otr updated, then the cascaded objects (usually children) are saveOrUpdate() too.
For more info on association management is to chech the APrent/Child relationship chapter and http://www.hibernate.org/155.html

_________________
Emmanuel


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