-->
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: what's the difference between cascade=all and .....
PostPosted: Wed Dec 03, 2003 3:18 am 
Beginner
Beginner

Joined: Wed Oct 29, 2003 5:27 am
Posts: 30
what's the difference between cascade=all and cascade=all-delete-orphan?
Have any examples about the difference?

thanks.
BTW. I have read the document attensively, but don't have a clear concept about it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 7:20 am 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Imagine you have Company (COMPANY table) and Employee (EMPLOYEE). Each Employee may work for several companies simultaneously so you create many-to-many mapping using COMPANY_EMPLOYEE table with two columns (COMPANY_ID, EMPLOYEE_ID)

Company has <set> named "employees" which contains all its employees. What happens when you load company and remove one of the items (Employees) from this set? Hibernate will remove association between particular Employee and particular Company - in fact, single record is removed from EOMPANY_EMPLOYEE table. Employee with given ID still exists in the EMPLOYEE table - it can be loaded and used the way you want.

But if you use all-delete-orphan cascading, Hibernate will also remove corresponding record from EMPLOYEE table effectively erasing that Employee.

all-delete-orphan is used when child objects can not exist without parent.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 04, 2003 8:56 pm 
Beginner
Beginner

Joined: Wed Oct 29, 2003 5:27 am
Posts: 30
thank you !
i'v got it.


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.