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.  [ 4 posts ] 
Author Message
 Post subject: NHibernate.HibernateException
PostPosted: Thu Aug 24, 2006 10:01 pm 
Newbie

Joined: Wed Aug 16, 2006 2:49 am
Posts: 14
"SQL insert, update or delete failed (expected affected row count: 1, actual affected row count: 0). Possible causes: the row was modified or deleted by another user, or a trigger is reporting misleading row count."

Have you encountered this one? I can't find any concrete answer to what's causing this kind of behavior. Below is my mapping.


<class name="WorkQueue" table="qu_queue">
<id name="Id">
<column name="qu_identifier"/>
<generator class="assigned" />
</id>
<property name="ParentId" column="qu_parent"/>
<property name="Name" column="qu_name"/>
</class>

In the table, Id is not autoincrement, and also not a primary key.

Here are the results of my tests.

1. I retrieve an existing workQueue, modify it's id to an already existing Id, save. = succesful.

2. Create an existing workqueue object, save. = succesful

3. I retrieve an existing workQueue, modify it's id to a non-existing id, save = failure. (the above exception shows up)

4. Create a non-existing workqueue object, save = failure. (above exception)



before, when id is still autoincrement and generator class is native, I had no problem saving a non-existing workqueue.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 25, 2006 4:50 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
with your id mapping you have to add your own logic whether to save or to update the object. This is the reason for the unsaved-value attribute, which is used by hibernate to decide whether is a save or an update.

cheers,
radu


Top
 Profile  
 
 Post subject: NHibernate.HibernateException
PostPosted: Fri Aug 25, 2006 4:58 am 
Newbie

Joined: Wed Aug 16, 2006 2:49 am
Posts: 14
Well, it already has logic whether to update or save.

Note that before, when auto increment is enabled, all goes well. No problem in the logic for saving and updating.

The Exception only occured after disabling the auto increment functionality of the table, and manually assigning the id of the class.


Top
 Profile  
 
 Post subject: Re: NHibernate.HibernateException
PostPosted: Fri Aug 25, 2006 5:10 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
kokoness wrote:
1. I retrieve an existing workQueue, modify it's id to an already existing Id, save. = succesful.

2. Create an existing workqueue object, save. = succesful

3. I retrieve an existing workQueue, modify it's id to a non-existing id, save = failure. (the above exception shows up)

4. Create a non-existing workqueue object, save = failure. (above exception)

before, when id is still autoincrement and generator class is native, I had no problem saving a non-existing workqueue.


For some reason, NHIbernate thinks that it should update or delete some object. Maybe You should show us real code, otherwise it is hard to guess what's going on.

Gert

_________________
If a reply helps You, rate it!


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

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.