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: cascade / delete / many to many
PostPosted: Tue Aug 15, 2006 1:15 pm 
Newbie

Joined: Fri May 05, 2006 4:54 am
Posts: 14
Hello!

I use NHibernate 1.02
I´ve been struggling with this in a couple of days now. But it´s surely a simple question to answer..) I got two tables contact and group, a many to many connection. And a table between named groupcontact.
When I add contacts to a group everything works fine, but how can i delete a contact from the contact table and get the groupcontact table updated with this deletion? I´ve tried with cascade = "delete" but this results in deletion of all contacts and all groups that that contact was tied to. I got inverse = "true" on the group side.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 16, 2006 8:31 am 
Newbie

Joined: Mon Mar 27, 2006 10:24 am
Posts: 8
Location: Malmoe, Sweden
I think you must delete the relationship in both ends as shown below

Code:
d.getEmployees().remove( e );
e.getDepartments().remove( d );
session.save( d );
session.save( e );


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.