Sven
Sven

Reputation: 371

Nhibernate bag is not saved

I'm trying to save an object that contains a bag with a many to many relationship. The problem is that the object is saved correctly but the bag isn't.

Here is my mapping, can anyone tell me what I'm doing wrong.

Thanks

<class name="XManager.Business.Afspraak, XManager.Business" table="Afspraak" lazy="false" mutable="false">
<id name="Id" type="int">
  <generator class="identity" />
</id>   
<property name="StartDatum" column="StartDatum"/>
<property name="EindDatum" column="EindDatum"/>
<property name="Herhalend" column="Herhalend"/>
<property name="HerhaalInterval" column="HerhaalInterval"/>
<property name="Opmerking" column="Opmerking"/>
<property name="Status" column="Status"/>
<property name="ToevoegDatumTijd" column="ToevoegDatumTijd"/>
<property name="WijzigDatumTijd" column="WijzigDatumTijd"/>

<many-to-one name="Klant" column="KlantId" class="Klant"/>

<bag name="Behandelingen" table="AfspraakBehandelingen" lazy="false" cascade="all-delete-orphan">
  <key column="AfspraakId"/>
  <many-to-many class="Behandeling" column="BehandelingId"/>
</bag>

<class name="XManager.Business.Behandeling, XManager.Business" table="Behandeling" lazy="false" mutable="false">
<id name="Id" type="int">
  <generator class="identity" />
</id>
<property name="Naam" column="Naam"/>
<property name="Omschrijving" column="Omschrijving"/>
<property name="Duur" column="Duur"/>
<property name="Prijs" column="Prijs"/>
<property name="ToevoegDatumTijd" column="ToevoegDatumTijd"/>
<property name="WijzigDatumTijd" column="WijzigDatumTijd"/>

<many-to-one name="Categorie" column="CategorieId" class="Categorie"/>

Upvotes: 1

Views: 547

Answers (1)

TheBoubou
TheBoubou

Reputation: 19933

Try inverse=true in the bag definition

Upvotes: 2

Related Questions