-->
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: "bidirectionnal" many-to-many
PostPosted: Wed Sep 10, 2003 5:48 pm 
Newbie

Joined: Mon Sep 08, 2003 3:04 pm
Posts: 12
Hi,
I'm under hb1.2.5
I've 2 tables with a many-to-many relation between :

<class name="com.model.offres.Service" table="services" >
<set
role="forfaits"
table="relations_forfaits_services"
cascade="none"
>
<key column="service_id"/>
<many-to-many
class="com.model.offres.Forfait"
column="forfait_id"
/>
</set>

<class name="com.model.offres.Forfait" table="forfaits" >
<set
role="services"
table="relations_forfaits_services"
cascade="none"
>
<key column="forfait_id"/>
<many-to-many
class="com.model.offres.Service"
column="service_id"
/>
</set>


With this kind of mapping, When I try
Set services = forfait.getServices();
services.remove(oneOfTheServices)
session.update(forfait)
session.flush()

Then the generated sql is a delete in the relations_forfaits_services followed with an insert in this table (the relation is re-built :-(

If I remove the <SET> in the Forfait.class hbm file then It's Ok,
I should keep this kind of bi-directionnality

How can I do ?

Thanks
Franck





Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 10:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate (and other ORM tools which are "transparent", ie. not CMP) does not implement "managed relationships". You need to adust *both* ends of the association.

Also, if you check the Hibernate documentation, it is recommended that you map one end of the association with inverse="true"


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.