본문 바로가기

코딩/자바

mybatis mysql insert Field 'id' doesn't have a default value error

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

 

스프링부트 마이바티스 mysql 인서트 할때 id를 안넣어줄때 에러가 난다

 

https://stackoverflow.com/questions/804514/hibernate-field-id-doesnt-have-a-default-value

 

Hibernate: "Field 'id' doesn't have a default value"

I'm facing what I think is a simple problem with Hibernate, but can't solve it (Hibernate forums being unreachable certainly doesn't help). I have a simple class I'd like to persist, but keep gett...

stackoverflow.com

CREATE TABLE `fm_board` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT, <= 자동 증가를 추가해주면 됨
  `created_date` datetime(6) DEFAULT NULL,
  `time` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci