报错:java.lang.RuntimeException: could not insert: [com.express.domain.House]; SQL [insert into Sys_Housing (CellName, Building, Unit, HouseNo, OwnerCardNo, OwnerPhoneNo, CreateDate, CreateUser, Status, Remark) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [com.express.domain.House]
问题分析:1.可能是由于某个字段在表设计时设置了不为null
解决:检查该字段传值是否为空
2.可能是.hbm.xml文件配置错误,
<id name="cellID" type="java.lang.String">
<column name="CellID" />
<generator class="native"></generator>
</id>
将上面改为:
<generator class="assigned"></generator>