While updating records using NHibernate, if we get the following exception :
could not delete collection: [CHILD_TABLE_NAME]
it is because of many to one relationship between two tables.
To resolve this exception,
we just need to add inverse="true" in mapping file of parent table. for e.g.,
<bag name="ChildTables" generic="true" inverse = "true">
<key>
<column name="ParentTableId" not-null="true" />
</key>
<one-to-many class="ChildTable" />
</bag>
<key>
<column name="ParentTableId" not-null="true" />
</key>
<one-to-many class="ChildTable" />
</bag>
No comments:
Post a Comment