-->
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: Cascading delete not complete
PostPosted: Tue Jan 20, 2004 12:53 pm 
Newbie

Joined: Fri Jan 09, 2004 9:55 am
Posts: 10
Location: Rutland, UK
Dear all

I have an object Contact which can have as many ContactNumbers as required. This is set up as a bag with a many-to-many relationship.

I can add as many ContactNumber objects to my Contact as I want and it works fine, and when I delete a Contact all child ContactNumber objects (and their references in the mapping table) are also deleted in the cascade.

If, however, I remove some of the ContactNumber objects from the Contact which I then pass it to the saveOrUpdate method it only deletes the references in the mapping table, not the actual contact numbers.

I have tried changing the cascade type from all to all-delete-orphan but without result - hope more than anything!

Any help/advice would be very welcome.

Nick.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2004 12:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
This is absolutely intended for a many to many. An object in a many-to-many relation is not just deleted because it is removed from the collection, in fact it may be part of yet another collection. Probably you rather have a many-to-one if you want to do that, please think about it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2004 3:13 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 1:46 pm
Posts: 20
How does Hibernate know that an object in a many-to-many relationship can be deleted or is the application responsible for determining this?

Thanks,
-Ben


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2004 3:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
There is no way that Hibernate could implement such a thing efficiently. It is up to the application.


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.