-->
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: nhibernate update trigger gives exception
PostPosted: Fri Jan 04, 2008 1:05 am 
Newbie

Joined: Tue Dec 18, 2007 7:11 am
Posts: 7
CREATE TRIGGER EMP_UPDATE ON EMP
FOR UPDATE
AS
IF UPDATE(ACTIVE_STATUS)
BEGIN
UPDATE EMP SET LAST_MODIFICATION_DATE = GETDATE()
FROM EMP
INNER JOIN INSERTED
ON EMP.id= EMP.id

END

giving exception because of two updations one by query and once by trigger.so count is 2 where as nhibernate expects 1.

SQL insert, update or delete failed (expected affected row count: 1, actual affected row count: 2). Possible causes: the row was modified or deleted by another user, or a trigger is reporting misleading row count. at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)

_________________
venkat


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 1:58 am 
Regular
Regular

Joined: Tue Feb 21, 2006 9:50 am
Posts: 107
You have to set "nocount on" / "nocount off" (see: http://jira.nhibernate.org/browse/NH-192)

Code:
CREATE TRIGGER EMP_UPDATE ON EMP
FOR UPDATE
AS
IF UPDATE(ACTIVE_STATUS)
BEGIN

set nocount on

UPDATE EMP SET LAST_MODIFICATION_DATE = GETDATE()
FROM EMP
INNER JOIN INSERTED
ON EMP.id= EMP.id

set nocount off

END


Regards
Klaus


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.