[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;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章