-->
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.  [ 2 posts ] 
Author Message
 Post subject: SqlCommand.ExecuteNonQuery() returns -1
PostPosted: Wed Aug 22, 2007 7:48 am 
Newbie

Joined: Wed Nov 22, 2006 7:28 am
Posts: 12
I'm using latest NHibernate.

I'm having this exception thrown when trying to SaveOrUpdate (and then do a Session.Flush) for a detached entity:
Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) for XXX.Brand instance with identifier: 105

I compiled NHibernate in debug to step through it and the cause of this problem and the error comes from when an SqlCommand is executed using ExecuteNonQuery(), this method then returns -1, once this happens the method Check in AbstractEntityPersister throws a StaleObjectStateException.

I don't have any triggers happening on any of the tables and I am not running the current queries within a transaction.

Any ideas why I am getting this -1 for the affected records count ?

PS: the relevant settings for the SessionFactory are:
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.isolation">ReadCommitted</property>
<property name="prepare_sql">false</property>
<property name="max_fetch_depth">1</property>
<property name="show_sql">true</property>
<property name="adonet.batch_size">0</property>


Cheers
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 22, 2007 10:06 am 
Newbie

Joined: Wed Nov 22, 2006 7:28 am
Posts: 12
Problem solved, the database was set up with NOCOUNT ON.
I ended up having to change the connection release mode to no_close so that it stays open during the web request using OSIV pattern.

Maybe NHibernate should have a setting per Session Factory to allow sending SET NOCOUNT OFF with every single database request ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.