Hibernate——org.hibernate.StaleStateException: Batch update returned unexpected row count from update
来源:互联网 发布:英语语言变迁 知乎 编辑:程序博客网 时间:2024/04/20 10:38
update 2.0:
我的id的类型用的是int,结果无论怎样都报错。后来将类型换为Integer,然后在更新数据之前,使用了setId方法设置了以下记录的ID,再更新就OK了。
总结:
主键最好使用Integer这样的包装类型,而不是int这样的基本类型!,这样可能会避免很多问题。
以下为1.0原文:
在使用hibernate更新数据库记录的信息时,出现org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 错误。
原因分析:
我在更新数据时,显式地使用了id的setId()方法为其指定值。但是我的实体类的id指定了主键生成策略(@GeneratedValue(strategy = GenerationType.AUTO)
),此时不能显式使用setId()方法设置id的值。
解决方法:
不要显式地使用setId方法设置主键值。
0 0
- Hibernate——org.hibernate.StaleStateException: Batch update returned unexpected row count from update
- org.hibernate.StaleStateException: Batch update returned unexpected row count
- org.hibernate.StaleStateException: Batch update returned unexpected row count
- org.hibernate.StaleStateException: Batch update returned unexpected row count
- org.hibernate.StaleStateException:Batch update returned unexpected row count from update [0]; actua
- org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actua
- org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actua
- SSH出现:org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0];
- org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actua
- org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actua
- org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual
- org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0];
- org.hibernate.StaleStateException: Batch update returned unexpected row count from upda
- org.hibernate.StaleStateException: Batch update returned unexpected row cou...
- Exception executing batch: org.hibernate.StaleStateException: Batch update returned unexpected row
- hibernate 错误 Batch update returned unexpected row count from update [0]; actual row count: 0;
- Hibernate - Batch update returned unexpected row count from update: 0 actual row count: 0 expected:
- Hibernate 报错:Batch update returned unexpected row count from update [0]; actual row count
- 中华人民共和国护照
- 浅谈urllib2中内部调用流程
- Prim算法生成最小生成树
- C#读取xml文件
- http协议介绍(servlet)
- Hibernate——org.hibernate.StaleStateException: Batch update returned unexpected row count from update
- 最大熵模型中的数学推导
- Arduino - 关于内存
- Canvas基础知识总结之一
- IIS7/8 HTTP Error 500.19 错误 0x80070021
- Java中的责任链模式
- sympy官方文档网站无法打开问题解决
- BAT巨头的开源项目
- Awesome R