강의

멘토링

로드맵

Inflearn Community Q&A

nbc058298756's profile image
nbc058298756

asked

[The concept is easy~, the practice is intense] Spring Boot, introduction!

17 CRUD and SQL Query (What happened in the DB?)

17강 ID 자동 생성 안됨 해결

Written on

·

485

·

Edited

3

스프링부트 2.7.7, h2 2.1.214 버전

@GeneratedValue(strategy = GenerationType.IDENTITY)

이렇게 생성하게 둬도 글을 새로만들면 id가 1로 만들어져

아이디 중복이라 오류가 뜨길래

 

INSERT INTO article( title, content) VALUES( '가가가가', '1111');
INSERT INTO article( title, content) VALUES( '나나나나', '2222');
INSERT INTO article( title, content) VALUES( '다다다다', '3333');

이렇게 data.sql에 id 지정값을 빼니 알아서 id 4로 해주며 잘 작동하네요

혹시 최신버전으로 하시는 분들중 오류가 있으면 참고하세요

DB 버전문제인거같은데 왜그런지는 잘 모르겠네요..

최신버전에서는 id를 지정해주면 IDENTITY가 작동안하는거 같기도 하네요

 

spring-boot

Answer 2

0

감사합니다

0

hongpark님의 프로필 이미지
hongpark
Instructor

공유, 아리가또 😘

nbc058298756's profile image
nbc058298756

asked

Ask a question