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.  [ 6 posts ] 
Author Message
 Post subject: Existing database with triggers - How to update?
PostPosted: Tue Jul 25, 2006 9:08 pm 
Newbie

Joined: Fri May 06, 2005 9:03 pm
Posts: 4
Hi,

I am using NHibernate 1.0.2 with existing database schema (Sybase) that has triggers. While doing a simple update operation that should modify ONE row I get the following exception message -

[NHibernate.HibernateException] {NHibernate.HibernateException}

{"SQL insert, update or delete failed (expected affected row count: 1, actual affected row count: 25). Possible causes: the row was modified or deleted by another user, or a trigger is reporting misleading row count." }

In this case there is a trigger that is indeed modifying 25 rows. I cannot disable/remove this trigger - and it does need to do its work and modify 25 rows. So how do I use NHibernate to do update with this database?

Having checked the NHibernate source - EntityPersister.Update() always checks to make sure that the number of expected updated rows matches the actual updated rows. So how do I use NHibernate in this situation?

Thanks

AbiMan


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 26, 2006 5:02 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
On SQL Server the solutiion is to have SET NOCOUNT ON in the triggers.
I think there is something similar in Sybase as well.

cheers,
Radu


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 26, 2006 1:16 pm 
Newbie

Joined: Fri May 06, 2005 9:03 pm
Posts: 4
Thanks,

This fixes the problem. But I cannot add the SET NOCOUNT ON in all of the triggers. Is there a way to tell NHibernate to ignore the update count returned by the database?


Top
 Profile  
 
 Post subject: triggers and 3rd party databases
PostPosted: Wed Oct 04, 2006 6:54 am 
Newbie

Joined: Wed Oct 04, 2006 6:13 am
Posts: 1
Unfortunately I cannot use the set nocount solution becuase I am querying a 3rd party database and as such am not allowed to alter their triggers.

Is there no other way to stop this problem?


Top
 Profile  
 
 Post subject: Re: triggers and 3rd party databases
PostPosted: Wed Oct 04, 2006 12:31 pm 
Newbie

Joined: Fri May 06, 2005 9:03 pm
Posts: 4
Which driver are you using? Check the driver documentation, it should have some flag to neglect the update count.

-abiman


Top
 Profile  
 
 Post subject: SET NOCOUNT ON produces an commit transaction error
PostPosted: Thu Apr 12, 2007 9:49 am 
Beginner
Beginner

Joined: Wed Aug 09, 2006 10:15 am
Posts: 20
Location: Vitoria - ES - Brazil
I am facing the same problem right now I dont know how to solve it.

If I set NOCOUNT on in the triggers the SaveOrUpdate method works but when I execute commit transaction ADO.NET raised an excpetion informing that it was expecting 2 rows ( for example ) but only one was returned.

If I set NOCOUNT off in the triggers the opposite happens and the SaveOrUpdate method NHibernate raises a row count misleading exception.

Are you having the same problem ?

How can I solve the problema without removing triggers ?

t+


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