I have a really annoying bug that I'm trying to troubleshoot. The most annoying part is that it only seems to happen in production!
Every once in a while (not often enough to be useful for troubleshooting, but often enough to make me look really bad), I get a foreign key violation during the Commit() indicating that NHibernate tried to save the child object before the parent object.
Alternately, it could be a bug where the child object reference to the parent object's ID is not getting set properly.
It ONLY happens on one type of object. I removed any special code for that object, but that didn't help.
It ONLY happens when trying to Save a new object, never when updating an existing object.
In the parent object (TravelAuthorization), the child object is mapped as follows
Code:
<bag name="LineItems"
table="AuthLineItem"
inverse="true"
cascade="all-delete-orphan"
access='NHibernate.Generics.GenericAccessor, NHibernate.Generics'
order-by="TravelStartDate"
lazy="true">
<key column="Authorization"/>
<one-to-many class="AuthLineItem"/>
</bag>
In the child object (AuthLineItem), the parent is mapped as follows
Code:
<many-to-one name="Authorization" class="TravelAuthorization" access='NHibernate.Generics.GenericAccessor, NHibernate.Generics' cascade="none" foreign-key="FK_AuthLine2Auth"/>
And one more thing, once the user tries to Save and gets this error, it keeps happening to them, suggesting it has something to do with the NHibernate Session being corrupted.
Anybody have any ideas?
(ASP.NET 2.0, IIS6, NHibernate 1.0.2)[/code]