티스토리 뷰

반응형

https://stackoverflow.com/questions/41149529/sql-error-1064-sqlstate-42000-caused-by-org-hibernate-exception-sqlgrammar

 

SQL Error: 1064, SQLState: 42000 - Caused by: org.hibernate.exception.SQLGrammarException: could not execute statement

I am really exhausted in solving the below error. Any help is very much appreciated. org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested

stackoverflow.com

https://vladmihalcea.com/escape-sql-reserved-keywords-jpa-hibernate/

 

How to escape SQL reserved keywords with JPA and Hibernate - Vlad Mihalcea

Learn how to escape SQL reserved keywords when using JPA and Hibernate. Reserved keywords can be escaped in table or column names.

vladmihalcea.com



나의 경우 예약어를 컬럼명으로 사용해서 발생한 이슈이다. 

문제

@Column(name = "read")
var read: Boolean = false

해결책

@Column(name = "\"read\"")
var read: Boolean = false

처음에는 `read` 이렇게 하다가 바꿨다.

P.S. 실제 라이브에 반영될 때에는 DBA님의 제안으로  컬럼명을 is_read로 변경했다.

 

반응형
댓글
댓글쓰기 폼