版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_29774479/article/details/78416336
ERROR [http-8080-Processor22] (BatchingBatcher.java:60) - Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
在使用hibernate框架进行对象的更新时 出现这个错误
仔细观察这句报错信息 update returned unexpected row count from update: 0 actual row count: 0 expected: 1
说明是因为在更新对象的时候没有找到需要更新的对象导致的问题
找到更新的对象发现是修改了需要更新的对象的id 导致更新该对象时 找不到该对象 所以无法进行更新操作
可以采用先使用delete方法删除原有id的对象在进行add方法插入新的id 的对象
那么
ERROR [http-8080-Processor22] (BatchingBatcher.java:60) - Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 2 actual row count: 2 expected: 1
就是因为update时查询需要更新的对象有两个 以此类推