Batch update returned unexpected row count from update [0]
来源:互联网 发布:js动态增加删除表格 编辑:程序博客网 时间:2024/04/27 23:13
1.Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1这个异常是由于主键设置为自增长,而在我们插入记录的时候设置了ID的值导致的。即在映射文件中,设置 <id name="id" column="ID" type="integer"><generator class="increment"/> </id>,而在插入数据时,又设置了ID值导致的。
若使用触发器时,出错的些错误:
解决方案:
原因分析:Nhibernate在对数据库执行更改操作时,会比较更改记录的数量与数据库返回的实际受 影响记录数(也就是@@ROWCOUNT的返回值),如果两者不一致,就会引发上述异常。而让数据库返回的实际受影响记录数发生变化的原因,就是在触发器 中执行了Update、Insert或Delete语句。而nocount开关的作用,就是让SQL Server在执行数据更改操作后不返回受影响记录数。只要在触发器脚本中执行数据库更改操作前打开nocount开关,就可以让Nhibernate得到正常的预期结果,进而消除此异常。
2.net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB setter of com.your.entity.classname.set***()
也是很常见的错误。引起此错误的原因很多,类型转换出错,NullPoinerExcption等。
这里说一下NullPointerException,Hibernate有一个问题,对于java类型为基本类型的字段,如果数据库中该字段为 null,则load数据时会触发NullPointerException,从而引起PropertyAccessException。
3.NHibernate中No row with the given identifier exists
产生此问题的原因:
有两张表,table1和table2.产生此问题的原因就是table1里做了关联<one-to-one>或者<many-to- one unique="true">(特殊的多对一映射,实际就是一对一)来关联table2.当hibernate查找的时候,table2里的数据没 有与table1相匹配的,这样就会报No row with the given identifier exists这个错.(一句话,就是数据的问题!)
假如说,table1里有自身的主键id1,还有table2的主键id2,这两个字段.
如果NHibernate设置的单项关联,即使table1中的id2为null值,table2中id2中有值,查询都不会出错.但是如果table1中的id2字段有值,但是这个值在table2中主键值里并没有,就会报上面的错!
如果NHibernate是双向关联,那么table1中的id2为null值,但是table2中如果有值,就会报这个错.这种情况目前的解决办法就是改成单项关联,或者把不对应的数据改对!
- Batch update returned unexpected row count from update [0]
- Batch update returned unexpected row count from update [0]
- Batch update returned unexpected row count from update [0]
- {"Batch update returned unexpected row count from update; actual row ?
- Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1解决方案
- Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- 错误Batch update returned unexpected row count from update [0]; actual row count: 0;
- Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- Batch update returned unexpected row count from update :0 actural row count 0, excepted :1
- Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- 错误:Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- mysql 垮服务、垮库查询 Federated引擎
- VMware虚拟机ubuntu系统和主机建立共享文件
- angular file upload 文件上传
- Android开发经验总结
- Linux内存管理之mmap详解
- Batch update returned unexpected row count from update [0]
- 重编译OpenCV库(Win7x64+VS2012+OpenCV2.4.3+CMake2.8.10+TBB41中)
- oracle group by rollup实现小计、合计
- Oracle中对数字加汉字的排序(完善)
- 采用nginx_upstream_jvm_route模块解决tomcat多节点session不一致问题
- 联系方式QQ:7632156 手机号:13754851215
- 使用popen的一个例子
- java中replace()和replaceAll()区别
- 期末学习总结