I've recently upgraded from NHibernate 1.2 to NHibernate 2.0.1.GA and an issue has occurred attempting to delete an object that references itself.
The mapping file:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" ..>
<class name="Account" table="Account" polymorphism="explicit">
<id name="ID" column="ID">
<generator class="identity" />
</id>
<many-to-one name="CreatedBy" column="CreatedBy" class="Account" />
<property name="CreatedOn" column="CreatedOn" />
<many-to-one name="ModifiedBy" column="ModifiedBy" class="Account" />
<property name="ModifiedOn" column="ModifiedOn" />
</class>
</hibernate-mapping>
If ModifiedBy references itself, then in NHibernate 2.0.1.GA a GenericADOException occurs saying it could not Update Account "Cannot insert the value NULL into column 'ModifiedBy'".
Why doesn't NHibernate just execute a DELETE to the Account table rather than first updating the ModifiedBy property to NULL? Am I missing something from the mapping file?