views:

35

answers:

1

i have this:

<set name="Identities" table="tIdentityGroups" inverse="true" batch-size="10" cascade="none">
      <cache usage="read-write" />
      <key column="GroupID" />
      <many-to-many class="Identity" column="IdentityId" />
</set>

and have translated it to this:

HasManyToMany<Identity>(x => x.Identities)
                .Table("tIdentityGroups")
                .ChildKeyColumn("IdentityID")
                .ParentKeyColumn("GroupID")
                .BatchSize(10)
                .Inverse()
                .Cascade.None()
                .Cache.ReadWrite();

The problem is that nothing is inserted in the tIdentityGroups table and my guess is that something is wrong with the mapping.

I dont know if the old nHibernate mapping worked before

Is there something i have done wrong with the new mapping or does the problem exist because of something else?

+2  A: 

You are declaring it as Inverse, which means the other side of the relationship is responsible for maintaining it.

That means you need to add your Group to the Identity's Groups property (which would not be Inverse) in order for the relationship to be persisted.

If you don't have a bidirectional relationship, remove the Inverse.

Diego Mijelshon