After some extensive debugging (including NH source) :wink: we found the source of our problem.
We're not sure if it something we did wrong and the previous versions let us get away with it or it was due to a bug.
The problem came from the following mapping:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping
xmlns="urn:nhibernate-mapping-2.0"
namespace="SAFJP.SICI.Model.Carteras"
assembly="SAFJP.SICI.Model.Carteras"
default-access="field">
<class
name="Recepcion"
table="T_Recepcion">
<id
name="mId"
column="recepcion_ID"
type="Int32"
unsaved-value="-1">
<generator class="native" />
</id>
<property
name="Dia"
column="D_recepcion"
type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate"
access="property"
not-null="true"
/>
<component
name="mFuentesYUsos"
class="FuentesYUsos">
<component
name ="mCuentas"
class="ICuentaCollection" >
<bag
name="mInternalCuentas"
table="T_Cuenta_Fuentes_Y_Usos"
order-by="Cuenta_ID"
cascade="all-delete-orphan"
lazy="true">
<key column="Recepcion_ID" />
<many-to-many column="Cuenta_ID" class="ICuenta"/>
</bag>
</component>
</component>
</class>
</hibernate-mapping>
ICuentaCollection is just a collection wrapper for ICuenta which is another mapped class.
The source for the bug was that we were setting the mFuentesYUsos to nothing as following:
Code:
recepcion.FuentesYUsos = nothing
and was replaced for
Code:
recepcion.FuentesYUsos.Cuentas.Clear()
NHibernate seems to be using the DELETE statement fine. Was puzzels me is how the code worked with previous versions and if this is a known enhanced enforcement. If so, could someone please explain it a bit better so that I we can check our code looking for such errors.
thanks!