错误Batch update returned unexpected row count from update [0]; actual row count: 0;

Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
不注意的话,还真的有点无所适从,Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1这个异常是由于主键设置为自增长,而在我们插入记录的时候设置了ID的值导致的。
Hibernate 注释@OneToOne 建立表关联实例

我的解决方案:
我是在做One-To-One级联 添加/更新 碰到的,开始还以为是我配置错误,后面经过仔细排查,发现是我在页面上写了子表ID的隐藏表单域,传到后面的时候value="" ,不是value=null,所以执行的时候hibernate判断为更新,所以报错了。我的解决方案是把ID单独传到后台,然后用代码判断是否为空,然后进行更新或者增加。

原文地址:https://www.cnblogs.com/htys/p/3284337.html