繁体   English   中英

org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException

[英]org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException

运行getsession.update(data)以下错误;

org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

请帮助我解决问题。

发生问题是因为批处理更新应该更新至少一行,但没有更新任何行。 因为您正在尝试更新该行,所以该行被删除,因此批量更新不会更新该行并抛出异常。

从文档:

公共类StaleStateException扩展了HibernateException
当版本号或时间戳检查失败时抛出,表明会话包含陈旧数据 (当使用带有版本控制的长事务时)。 如果我们尝试删除或更新不存在的行,也会发生这种情况
请注意,此异常通常表明用户未能为类指定正确的未保存值策略!

因此,请检查:

  1. 数据库中是否存在更新实体?
  2. 是否对实体进行过任何修改以使其过时?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM