运行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
请帮我解决问题。
答案 0 :(得分:0)
问题正在发生因为批量更新应该更新至少一行,但它没有更新任何行。因为您正在尝试更新该行被删除的行,因此批量更新不会更新该行并抛出异常。
答案 1 :(得分:0)
来自文档:
public class StaleStateException扩展了HibernateException
当版本号或时间戳检查失败时抛出,表明会话包含 陈旧数据 (当使用版本控制的长事务时)。如果我们 尝试删除或更新不存在的行 ,也会发生这种情况。
请注意,此异常通常表示用户未能为类指定正确的未保存值策略!
所以,检查: