如何解决“批量更新从更新返回意外的行数;实际行数:0;预期:1“问题? [英] How to solve "Batch update returned unexpected row count from update; actual row count: 0; expected: 1" problem?

查看:783
本文介绍了如何解决“批量更新从更新返回意外的行数;实际行数:0;预期:1“问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次尝试创建一个特定的实体...只是想知道我应该如何找出原因。



我使用Fluent NHibernate的自动映射,所以也许我没有适当地设置一个约定和/或需要重写一个或多个映射文件中的一些东西。我已经通过在网络上的这个问题的一些帖子,并很难弄清楚为什么发生在我的情况。



对象我'节约很简单。它是引用公司实体并具有地址实体集合的人对象。 UPDATE在已经存在于数据库中的现有Person对象上工作正常。



建议?

Thanks -wg <解决方案

错误表示正在执行SQL INSERT语句,但SQL Server运行后返回的ROWCOUNT为0,不是预期的。



有几个原因,从不正确的映射到关闭rowcount的UPDATE / INSERT触发器。

你最好的办法是分析SQL语句,看看会发生什么。要做到这一点,打开 nHibernate的SQL日志记录,或使用sql分析器。一旦你有SQL你可能知道原因,如果不尝试手动运行SQL,看看会发生什么。



另外,我建议你发布你的贴图,因为这会帮助人们发现任何问题。


Getting this everytime I attempt to CREATE a particular entity ... just want to know how I should go about figuring out the cause.

I'm using Fluent NHibernate automapping so perhaps I haven't set a convention appropriately and/or need to override somethings in one or more mapping files. I've gone thru a number of posts on the web regarding this problem and having a hard time figuring out exactly why it is happening in my case.

The object I'm saving is pretty simple. It is a "Person" object that references a "Company" entity and has a collection of "Address" entities. UPDATES work fine on existing Person objects that are already in the database.

Suggestions?

Thanks -wg

解决方案

The error means that the SQL INSERT statement is being executed, but the ROWCOUNT being returned by SQL Server after it runs is 0, not 1 as expected.

There are several causes, from incorrect mappings, to UPDATE/INSERT triggers that have rowcount turned off.

Your best beat is to profile the SQL statements and see what happens. To do that either turn on nHibernate sql logging, or use the sql profiler. Once you have the SQL you may know the cause, if not try running the SQL manually and see what happens.

Also I suggest you to post your mapping, as it will help people spot any issues.

这篇关于如何解决“批量更新从更新返回意外的行数;实际行数:0;预期:1“问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆