Hibernate出现Caused by: java.sql.SQLException: Field 'id' doesn't have a default value原因
2013-07-12 15:50
302 查看
因为设计mysql的时候主键id没有设置为自增造成的
本来不设置也没事,但是如果字段用了主键策略就不行了,例如用了注解的
所以,更改表结构就可以了
更改表结构语句方法
返回执行结果:
本来不设置也没事,但是如果字段用了主键策略就不行了,例如用了注解的
@GeneratedValue(strategy=GenerationType.IDENTITY)
所以,更改表结构就可以了
更改表结构语句方法
alter table hib_user modify column id int auto_increment;
返回执行结果:
Hibernate: insert into hib_user (name) values (?)
相关文章推荐
- hibernate 出现Caused by: java.sql.SQLException: Column 'id' not found.异常
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- Caused by: java.sql.SQLException: Field 'stu_id' doesn't have a default value
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value .
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- java.sql.SQLException: Field 'id' doesn't have a default value解决方案
- ### Cause: java.sql.SQLException: Field 'id' doesn't have a default value
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- java.sql.SQLException: Field 'id' doesn't have a default value
- java.sql.SQLException: General error, message from server: "Field 'ID' doesn't have a default value
- java.sql.SQLException: Field 'id' doesn't have a default value
- sql查询报java.sql.SQLException: Column 'LC_ID' not found 的错误实际上是mysql在hibernate别名的问题
- java.sql.SQLException: Field 'id' doesn't have a default value解决方法
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- 自增长:java.sql.SQLException: Field 'id' doesn't have a default value
- sql查询报java.sql.SQLException: Column 'LC_ID' not found 的错误实际上是mysql在hibernate别名的问题
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- Hibernate插件出现错误 java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver