-->
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: Error deleting with a n-m relation
PostPosted: Fri Mar 19, 2004 8:51 am 
Newbie

Joined: Thu Mar 11, 2004 5:39 am
Posts: 13
Hi,
I have a Man class that contains a Set ou House class.
The House class also contains a Set of Man class.
So there is a n-m relationship between Man and House that goes both way, which means there is a relationship table between Man and House that stores Man.id and House.id.

If I declare the in Man mapping:

<set name="houses" table="MAN_HOUSE" inverse="true" lazy="true">
<key column="MAN_ID"/>
<many-to-many class="House" column="HOUSE_ID"/>
</set >

and in the House mapping:

<set name="men" table="MAN_HOUSE" lazy="true">
<key column="HOUSE_ID"/>
<many-to-many class="Man" column="MAN_ID"/>
</set >

when I use Session.delete(Man) then Hibernate deletes from MAN_HOUSE (the relationship table) before deleting from Man, which is correct.

BUT, when I use Session.delete(House) then Hibernate doesn't delete from MAN_HOUSE before deleting from House, which is bad!

Any idea what needs to be modified to make this work?

thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 24, 2004 6:26 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You have to remove the link from both side (Java speaking) before flushing.

_________________
Emmanuel


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.