读书人

Batch update returned unexpected ro

发布时间: 2012-09-02 21:00:34 作者: rapoo

Batch update returned unexpected row count from update [0]; actual row count
异常:
Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

原因:
这个异常是由于主键设置为自增长,而在我们插入记录的时候设置了ID的值导致的。

解决方案:
我在页面上写了子表ID的隐藏表单域,传到后面的时候value="" ,不是value=null,所以执行的时候hibernate判断为更新,因此报错。我的解决方案是把ID传到后台,然后用代码判断是否为空,然后进行更新或者增加。

if ("".equals(dsTaskId)) {dsTaskId = null;}

读书人网 >PowerDesigner

热点推荐