hibernate错误记录-hibernate主键生成策略导致Column 'id' cannot be null

配置文件代码段:

<id name="id">

<generator class="native"></generator>

</id>

错误详情:

Hibernate: insert into student (id, name) values (null, ?)

hibernate.exception.ConstraintViolationException: could not insert: [fh.model.Student]

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' cannot be null

解决思路;

hibernate.exception.ConstraintViolationException:主键约束异常!

表student主键id不是自动增长导致!

猜你喜欢

转载自happyfling.iteye.com/blog/2314127
今日推荐