Spring & SpringBoot

SpringBoot&JPA : CommandAcceptanceException

땅콩콩 2024. 1. 21. 21:49

스프링부트 프로젝트에서 JPA 엔티티를 만들고 데이터베이스에 반영하려고 하는데 이런 오류가 났다.

로그를 보다보니 Caused by: java.sql.SQLSyntaxErrorException이라고도 하고..

그래서 순간 sql 예약어가 있나 하는 생각이 쎄하게 들었고 찾아봤더니 이게 맞다고 한다... ..

 

https://dev.mysql.com/doc/refman/8.0/en/keywords.html#keywords-8-0-detailed-U

 

MySQL :: MySQL 8.0 Reference Manual :: 9.3 Keywords and Reserved Words

9.3 Keywords and Reserved Words Keywords are words that have significance in SQL. Certain keywords, such as SELECT, DELETE, or BIGINT, are reserved and require special treatment for use as identifiers such as table and column names. This may also be true

dev.mysql.com

 

나의 경우, User라는 예약어를 엔티티명으로 지정하고있어서 해당 오류가 났던 것 같다. ㅡㅡ;

ㅋ...

그래서 해당 부분을 Member로 바꾸고 관련 필드명들도 모두 교체했더니 문제를 해결할 수 있었다!

(Member도 이전에는 예약어였지만 8.0.19 이후로는 nonreserved되었다고 한다. 출처는 위 링크.)