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: Affected Row count is off when updating a detailsview
PostPosted: Mon Oct 02, 2006 6:53 pm 
Newbie

Joined: Mon Oct 02, 2006 6:36 pm
Posts: 2
Hibernate version: 1.2.0 beta1

Name and version of the database you are using: MS SQL Server 2005

I'm really new to all this database work so be easy with me.

I simply have a details view that when you hit the update linkbutton within it is supposed to update the entry. It only spits this error message when I change the key field but it won't throw it if I only change a regular field.

EX: the detailsview has 3 fields
Name (Key field and string) , Address (string), Enabled (bit).

If I change the Name it crashes.
If I change just the address or the enabled or both but not the name then it is fine.

I get this server error:

"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."

I suspect it has to do with the mapping files because if i change the Name field to "any" for the unsaved-value then it saves fine but instead of just updating the record in the DB it adds another new record with the updated fields.

Not sure if this is enough to solve the problem but just be easy on me. Like I said, I'm really really new to this stuff.


Top
 Profile  
 
 Post subject: Re: Affected Row count is off when updating a detailsview
PostPosted: Tue Oct 03, 2006 3:27 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
Tripleg wrote:
I simply have a details view that when you hit the update linkbutton within it is supposed to update the entry. It only spits this error message when I change the key field but it won't throw it if I only change a regular field.


AFAIK it is not allowed to change the value of primary key in NHIbernate.

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 03, 2006 3:30 am 
Newbie

Joined: Mon Oct 02, 2006 6:36 pm
Posts: 2
Thanks for the reply.

I do understand that it won't let me change the primary key. So the question is how do I get around that. In essence how can I get it to update correctly?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 03, 2006 3:54 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
Tripleg wrote:
I do understand that it won't let me change the primary key. So the question is how do I get around that. In essence how can I get it to update correctly?

Add a non-changeable surrogate primary key to the object.

Changeable primary keys are usually considered to be a bad design.

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.