Dearest All,
I have a one-directional many-to-many association: the ListDefinition class has the Columns property of type IList, while a column can be part of several ListDefinition-s. The problem is, whenever I try to remove a column from one Columns collection (without deleting it or removing from other ListDefinitions), I'm getting this error:
deleted object would be re-saved by cascade (remove deleted object from associations)[Domain.Lists.Definitions.ListColumnDefinition#2]
My mapping is generated via Fluent NH:
mapping.HasManyToMany(list => list.Columns)
.AsList(part => part.Column("`index`"))
.Cascade.AllDeleteOrphan()
Here's the generated hbm:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="property" auto-import="true" default-cascade="all" default-lazy="false">
<class xmlns="urn:nhibernate-mapping-2.2" mutable="true" name="Domain.Lists.Definitions.ListDefinition, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="ListDefinition
">
<id access="nosetter.camelcase-underscore" name="Id" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Id" />
<generator class="identity" />
</id>
<list cascade="all-delete-orphan" name="Columns" table="ListColumnDefinitionToListDefinition" mutable="true">
<key>
<column name="ListDefinition_id" />
</key>
<index>
<column name="index
" />
</index>
<many-to-many class="Domain.Lists.Definitions.ListColumnDefinition, Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<column name="ListColumnDefinition_id" />
</many-to-many>
</list>
</class> </hibernate-mapping>