异常:Batch update returned unexpected row count from update [0]; actual row count: 0;
Posted MJBrian
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了异常:Batch update returned unexpected row count from update [0]; actual row count: 0;相关的知识,希望对你有一定的参考价值。
使用了hibernate的主键生成策略,而在程序中又主动去设置了主键值。<class name="ProductRegion" table="PRODUCT_REGION" lazy="false">
<id name="id" column="PRODUCT_REGION_ID">
<generator class="native" />
</id>
<many-to-one class = "gira.domain.place.Region" name="region" column="PRODUCT_REGION_REGION_ID" />
<many-to-one class = "Product" name="product" column="PRODUCT_REGION_PRODUCT_ID" ></many-to-one>
<property name="index" column="PRODUCT_REGION_INDEX" />
</class>
程序中:
for(Long l:regionIds){
Region region=regionDao.findById(l);
ProductRegion productRegion=new ProductRegion();
productRegion.setProduct(product);
productRegion.setRegion(region);
productRegion.setId(i);
i++;
productRegions.add(productRegion);
}
从而出现异常了
以上是关于异常:Batch update returned unexpected row count from update [0]; actual row count: 0;的主要内容,如果未能解决你的问题,请参考以下文章
关于Hibernate级联更新插入信息时提示主键不为空的问题“org.hibernate.StaleStateException: Batch update returned unexpected r
Hibernate 抛出的 Could not execute JDBC batch update