Hibernate出现Caused by: java.sql.SQLException: Field 'id' doesn't have a default

因为设计MySQL的时候主键id没有设置为自增造成的
本来不设置也没事,但是如果字段用了主键策略就不行了,例如用了注解的

@GeneratedValue(strategy=GenerationType.IDENTITY) 

所以,更改表结构就可以了
更改表结构语句方法

alter table hib_user modify column id int auto_increment; 

猜你喜欢

转载自chimpp55.iteye.com/blog/2382469