Batch update returned unexpected row count from update [零]; actual row count

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;}