Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update

版权声明:本文为博主原创文章,请评论后转载,谢谢合作!!! https://blog.csdn.net/qq_33247435/article/details/88345439

进行数据库操作时,报错如下:
org.springframework.orm.hibernate5.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
报错原因:我是用的是hibernate数据库的update方法,此方法会更新数据库中的记录。若数据库中没有该主键的对应的记录。则运行该语句时就会报错,不知道该更新哪条数据。
一般情况下不会遇到这种bug,除非是在测试中,所有数据都是伪造的。就容易出现数据库主键不一致。

猜你喜欢

转载自blog.csdn.net/qq_33247435/article/details/88345439