-->
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.  [ 2 posts ] 
Author Message
 Post subject: delete many-to-many
PostPosted: Wed Sep 27, 2006 7:27 am 
Newbie

Joined: Wed Sep 27, 2006 6:08 am
Posts: 2
Hi,

i've got a question about a many-to-many relation.

I mapped a Person to an institute. So one Person can work in many institutes and in one institute works a lot of people.

The Hibernate creates 3 tables. One for the persons, one fpr the institutes and on for the relation. Now my problem:

When I delete an institute. I also want to delete the relation in the table. I set the parameter cascade="all-delete-orphan" but I still got an exception:

"org.hibernate.exception.ConstraintViolationException: could not delete: "

Maybe one of you can help me?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 10:03 am 
Newbie

Joined: Wed Nov 23, 2005 5:01 am
Posts: 15
Hi,

For many-to-many association you don't need to set any cascade style for deleting only if you want to save/persist the related entity, but I guess is not your case.
When you delete an Institute the relations will be deleted automatically even if you don't have any cascade style set.

The error appear now because you want to delete an Institute and also the Person's entities that are associated with that Institute, that is the effect of using cascade style, and I am sure that you have some of those Person's entities that are related also with other Institute.

I hope this help.
Calin.

_________________
I hope this help.
Calin


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