[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - BatchedTooManyRowsAffectedException: SqlServer trigger

whafrog do-not-reply at jboss.com
Thu Aug 9 09:31:06 EDT 2007


Hi, I'm having a problem with a legacy app that uses SQLServer 2000 that we're converting to EJB3.  One of the tables has a trigger on it to record audit changes.  However, the way the trigger and the audit repository work is, it creates a new record for each changed field in the target table.  Two fields are always updated (last update time, and user) so changing even one field causes hibernate to think three records were updated instead of the expected one record.

I get the following exception:

org.hibernate.jdbc.BatchedTooManyRowsAffectedException: Batch update returned unexpected row count from update [0]; actual row count: 3; expected: 1

I think the hibernate engine is using @@rowcount to get the number of updated rows, but the trigger messes this up.

The database folks aren't much interested in changing their auditing practice  :-( so I'm wondering if there's a way to change the hibernate configuration to deal with this.

Any suggestions?  TIA,

Jon


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4072501#4072501

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4072501



More information about the jboss-user mailing list