org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actua
2014-02-28 18:35
363 查看
hibernate更新数据的时候,如果数据不存在,就报org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 这个错误。报错的信息有点像junit的断言。期望的是一行,实际上是0行。
我的更新方法是: this.getHibernateTemplate().update(entity);
解决办法就是:自己写sql语句。
--------------------------------------------------
为什么会这样呢?我敢肯定的是jdbc如果执行更新操作的时候,如果数据库里面没有对应的数据,不会报错。而hibernate的官方文档明确说明了,如果没有数据而执行了更新操作,就报以上的错误。
我的更新方法是: this.getHibernateTemplate().update(entity);
解决办法就是:自己写sql语句。
--------------------------------------------------
为什么会这样呢?我敢肯定的是jdbc如果执行更新操作的时候,如果数据库里面没有对应的数据,不会报错。而hibernate的官方文档明确说明了,如果没有数据而执行了更新操作,就报以上的错误。
相关文章推荐
- 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];
- org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
- org.hibernate.StaleStateException: Batch update returned unexpected row count from upda
- org.hibernate.StaleStateException:Batch update returned unexpected row count from update [0]; actua
- org.hibernate.StaleStateException: Batch update returned unexpected row count
- org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual
- SSH出现:org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0];
- org.hibernate.StaleStateException: Batch update returned unexpected row cou...
- Hibernate——org.hibernate.StaleStateException: Batch update returned unexpected row count from update
- Hibernate 多对多关联出现报错情况---Batch update returned unexpected row count from update
- org.hibernate.StaleStateException: Batch update returned unexpected row count
- hibernate 报错: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 解决方法
- hibernate中主键与unsaved-value关系(Batch update returned unexpected row count from update)
- 关于使用S2SH,用hibernate执行删除出现的 Batch update returned unexpected row count from update: 0 actual row coun
- org.hibernate.StaleStateException: Batch update returned unexpected row count
- Hibernate 报错:Batch update returned unexpected row count from update [0]; actual row count
- Hibernate - Batch update returned unexpected row count from update: 0 actual row count: 0 expected:
- 关于Hibernate的 Batch update returned unexpected row count from update异常