These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Heisenbug: Foreign key violation due to cascades, but rarely
PostPosted: Wed Jul 12, 2006 5:23 pm 
Beginner
Beginner

Joined: Wed Jun 01, 2005 3:22 pm
Posts: 38
Location: Menlo Park, CA
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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.