I've a very strange problem. NHibernate is capable of deleting a single item, but it refuse to delete them all.
I'm getting a "NHibernate.ObjectDeletedException : deleted object would be re-saved by cascade (remove deleted object from associations): 18, of class: Model.Assignment" error when it happens.
I'm doing something like:
session.Delete("from Assignment");
And it fails.
Trying to do delete a single item.
I can't figure out why this is happening!
The mapping is here:
Code:
<hibernate-mapping xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.0">
<class name=".Model.FixedWorkPlanAssignment, .Model" table="FixedWorkPlanAssignments" >
<id name="Id" access="nosetter.camelcase-underscore" column="WorkPlanAssignmentId" type="Int32" unsaved-value="0">
<generator class="native">
</generator>
</id>
<property name="_occupationId" access="field" column="OccupationId" type="Int32" />
<property name="AssignmentDays" access="property" column="AssignmentDays" />
<property name="CycleType" access="property" column="CycleType" />
<many-to-one name="BoardTemplate" access="NHibernate.Generics.GenericAccessor, NHibernate.Generics" class=".Model.BoardTemplate, .Model" column="BoardTemplateId" />
<many-to-one name="FixedWorkPlan" access="NHibernate.Generics.GenericAccessor, NHibernate.Generics" class=".Model.FixedWorkPlan, .Model" column="WorkPlanId" />
<many-to-one name="ShiftTemplate" access="NHibernate.Generics.GenericAccessor, NHibernate.Generics" class=".Model.ShiftTemplate, .Model" column="ShiftTemplateId" />
<many-to-one name="TaskTemplate" access="NHibernate.Generics.GenericAccessor, NHibernate.Generics" class=".Model.TaskTemplate, .Model" column="TaskTemplateId" />
</class>
</hibernate-mapping>
Here is what fails:
Code:
session.Delete("from Model.Assignment");
session.Flush();
[/code]