Caused by: java.sql.SQLException: Field 'id' doesn't have a default value

建表语句:

create table t(

id int not null primary key,

name varchar(20) not null

);


原因:

*.hbm.xml文件中的配置<generator class="native" />

解决办法:

删除*.hbm.xml文件中的<generator class="native" />或者改为<generator class="assigned" />等。

如果觉得本文对您有帮助,请“打赏”,谢谢。
您的鼓励,我的动力。
微信 支付宝
原文地址:https://www.cnblogs.com/zongzhankui/p/5875347.html