标签:
org.springframework.dao.DataIntegrityViolationException: could not insert: [com.integration.entity.User]; SQL [insert into USER1 (NAME, PASSWORD, TYPE) values (?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [com.integration.entity.User]
出现这种错误的原因在于ConstraintViolationException,即违反约束异常,原来在这个user1表中,还有一个主键ID,这个主键必须是非空而且唯一的,但插入数据的时候只插入了三列,出现这种异常的原因就在于user.hbm.xml文件配置的错误,如果是oracle数据库,将文件中的内容更新为如下即可。
<class name="com.integration.entity.User" table="USER1">
<id name="id" type="java.lang.Integer">
<column name="ID" precision="11" scale="0" />
<generator class="increment" />
数据库问题ConstraintViolationException: could not insert
标签:
原文地址:http://www.cnblogs.com/beijinglan/p/4694597.html