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.  [ 1 post ] 
Author Message
 Post subject: deleting from many-to-many mapping doesn't work
PostPosted: Thu Apr 05, 2007 12:18 pm 
Newbie

Joined: Thu Apr 05, 2007 12:12 pm
Posts: 2
Hi,


I’m using a bidirectional many-to-many association in NHibernate. So I’ve got 3 tables named Aanpassing, Module and the table linking both: AanpassingModules.
I created a bag in both Dao’s.

For Module that’s:

Code:
<bag name="Aanpassingen" lazy="true" table="AanpassingModules" inverse="true" fetch="join">
      <key column="module" />
      <many-to-many class="Cevi.CeXLS.Hibernate.Aanpassing, Cevi.CeXLS.Hibernate" column="aanpassing" />
</bag>


In Aanpassing I’ve got this:
Code:
<bag name="Modules" lazy="true" table="AanpassingModules" fetch="join">
      <key column="aanpassing" />
      <many-to-many class="Cevi.CeXLS.Hibernate.Module, Cevi.CeXLS.Hibernate" column="module" />
</bag>


Which provides a collection of Modules for each Aanpassing and a collection of Aanpassingen for each Module.

Adding an association works fine, I just do the following:
Code:
anAanpassing.Modules.Add(aModule);
aModule.Aanpassingen.Add(anAanpassing);


And I perform SaveOrUpdate on both Dao’s.
My only problem is deleting an association.

I’ve tried a lot of things, without succes, hopefully someone can help me out. I’ve got this in my code at the moment:

Code:
aModule.Aanpassingen.Remove(anAanpassing);
moddao.SaveOrUpdate(aModule);
moddao.CommitChanges();

anAanpassing.Modules.Remove(aModule);
apdao.SaveOrUpdate(anAanpassing);
apdao.CommitChanges();



thanks in advance![/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.