본문 바로가기

성장 일기/오류 해결

[Spring/SQL/IntelliJ] could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement (2021-08-29)

오류

오류를 잘 읽어보면 

Unknown column 'phone_number' in 'field list'라고 나와있다. 

 

이는 DB에서 해당 테이블에서 필드 명을 phone_number라고 안하고 phone이라고 설정해둔 상태에서 프로젝트에서 Entity에서의 필드명은 phoneNumber이라고 설정해두었기 때문에 발생한 오류였다.

 

이럴 경우,

1. Entity에서 해당 필드명을 phone으로 바꾼다.

2. DB에서 해당 필드명을 phone_number로 바꾼다.

 

둘 중 하나를 선택하면 되는데 나는 후자를 선택해 오류를 해결했다.