-->
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: Help with Unexpected row count: 0 expected 1 on delete
PostPosted: Sun Dec 05, 2010 4:39 pm 
Newbie

Joined: Sun Nov 28, 2010 2:01 am
Posts: 3
I'm getting a StaleStateException when I try to delete an object. The message is "Unexpected row count: 0; expected: 1". The issue seems to be that Hibernate is deleting from the bag twice:

NHibernate.SQL: 2010-12-05 03:42:04,950 [11] DEBUG NHibernate.SQL [(null)] - DELETE FROM FieldInstance WHERE fkObjectInstanceId = @p0;@p0 = 6 [Type: Int32 (0)]
NHibernate.SQL: 2010-12-05 03:42:04,968 [11] DEBUG NHibernate.SQL [(null)] - DELETE FROM FieldInstance WHERE fieldInstanceId = @p0;@p0 = 19 [Type: Int32 (0)]

The delete on fkObjectInstanceId is sufficient, and removes any items that would be removed by deleting the specific field identifier. Here is my mapping:

<bag name="Fields" table="FieldInstance" lazy="true" cascade="all">
<key column="fkObjectInstanceId"/>
<many-to-many class="FieldInstance" column="fieldInstanceId" />
</bag>
The thing is, there is a many-to-many here and the column is the tables primary key. This is because it is used to generate the field instance class.

I couldn't see an attribute to tell NHibernate NOT to prioritise for deletion.

Suggestions?


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.