Unexpected row count: 0 expected: 1
来源:互联网 发布:淘宝美工岗位面试问题 编辑:程序博客网 时间:2024/04/28 11:30
看上面的异常信息有一条:Unexpected row count: 0 expected: 1
你正在调用saveOrUpdate往主键里添值,当主键被设置时saveOrUpdate产生了Update而不是insert
即Hibernate: update Card set NAME=?, STU_ID=? where id=?
由于Card表格里主键id没有值所以产生了错误!!
因而只需要使关联操纵时不是用Update就解决了问题!!
使用的是hibernate的saveOrUpdate方法保存实例。saveOrUpdate方法要求ID为null时才执行SAVE,在其它情况下执行UPDATE。在保存实例的时候是新增,但你的ID不为null,所以使用的是UPDATE,但是数据库里没有主键相关的值,所以出现异常。
- Unexpected row count: 0 expected: 1
- org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1
- org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1
- org.hibernate.StaleStateException: Unexpected 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
- 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
- GML、SVG、VML的比较
- 理解编译预处理
- 正确使用内存
- COM 组件设计与应用(五)---用 ATL 写第一个组件
- 关于指针与函数的几点小结
- Unexpected row count: 0 expected: 1
- C语言文件操作
- C语言中的valatile关键字
- [转]C语言嵌入式系统编程修炼(一)
- COM 组件设计与应用(六)---用 ATL 写第一个组件
- [转]C语言嵌入式编程修炼(二)
- 在xp IIS上搭建动易论坛注意事项
- 深圳公务员连续两年考核不称职将被辞退
- C语言嵌入式系统编程修炼(三)