NHibernate many-to-many relationship does not update join-table

Posted by Davide Vosti on Stack Overflow See other posts from Stack Overflow or by Davide Vosti
Published on 2010-06-06T16:37:38Z Indexed on 2010/06/06 16:42 UTC
Read the original article Hit count: 259

Filed under:
|

I'm having trouble saving a many-to-many relationship with nhibernate. I searched and looked at almost every same question in SO and google but nothing works. The single classes are update correctly but nothing is inserted in the join-table.

I have 2 classes: Event and Category.

The mapping is this:

Event:

<bag name="Categories" access="field.camelcase-underscore" table="EventCategories" inverse="true" cascade="all-delete-orphan" lazy="true">
  <key column="Event"/>
  <many-to-many class="Category" column="Category"/>
</bag>

Category:

<bag name="Events" table="EventCategories" access="field.camelcase-underscore" cascade="all-delete-orphan"  lazy="true" >
  <key column="Category"/>
  <many-to-many class="Event" column="Event"/>
</bag>

I tried to swap every parameter in both mappings but nothing works...

Do you know what I'm doing wrong or have a right mapping for this case?

Thank you very much!

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about many-to-many