[JPA] Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "\000d\000a ~~unique ([*]order)"; expected "identifier"; SQL statement: 에러

현주·2022년 12월 12일
0

Trouble Shooting

목록 보기
14/29

🔥 문제

Todo 프로젝트 하던 중에 아래와 같은 에러를 만났다 !

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "\000d\000a create table todos (\000d\000a todo_id bigint generated by default as identity,\000d\000a completed boolean not null,\000d\000a [*]order bigint not null,\000d\000a title varchar(255) not null,\000d\000a primary key (todo_id)\000d\000a )"; expected "identifier"; SQL statement:

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "\000d\000a alter table todos \000d\000a add constraint UK_nkg09qb0n4yetctnk80rppxkp unique ([*]order)"; expected "identifier"; SQL statement:

흠 일단 사진으로 봤을 때

Entity 쪽에서 테이블에 필드들이 매핑되는 부분에서 뭔가 에러가 난 것 같긴 했는데

정확히는 무슨 말인지 몰라서 검색했다 !


💡 원인

원인은 !!

원래 테이블에 필드명이 테이블명으로 매핑될 때, 모두 대문자로 변환되어 매핑되는데,

내가 order 필드를 그대로 테이블에 매핑해서

사용되면 안되는 예약어인 ORDER이 사용되어 나타나는 에러였던 것 !

( ❗ MYSQL에 ORDER BY 명령어가 있음 ! )


☘️ 해결

그래서 아래와 같이 Column의 이름을 orders로 바꾸고 실행했더니 해결되었다 ㅎㅎ

0개의 댓글