[hibernate] org.hibernate.exception.GenericJDBCException: could not execute statement.md

org.hibernate.exception.GenericJDBCException: could not execute statement

problem

hibernate 添加数据报错

reason

数据库字段定义为 not null
字段不能为空

solution

将数据库字段的属性 not null 改为allow null

例如:

CREATE TABLE `User` (
  `id` int NOT NULL AUTO_INCREMENT,
  `username` varchar(100) COLLATE utf8mb4_general_ci,
  `age` int,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
posted @ 2022-02-25 16:37  周雪zzz  阅读(185)  评论(0)    收藏  举报