Query_syntax_exception: foo is not mapped

최대 1 분 소요

“QuerySyntaxException: posts is not mapped…”

error error

테스트 코드를 돌리니 위와 같은 에러가 났다.

구글링을 하니 JPQL은 대부분 대소문자 구분이 없지만, 이를 구분하는 경우 중 하나는 자바 객체명이라고 한다. 즉, 테이블과 매핑된 도메인의 클래스명과 같아야한다.

“JPQL mostly is case-insensitive. One of the things that is case-sensitive is Java entity names. Change your query to…”

그래서 posts의 소문자 p를 대문자로 바꾼 Posts 로 변경하니 해결되었다.

@Query("SELECT p FROM Posts p ORDER BY p.id DESC")


참조) https://stackoverflow.com/questions/8230309/jpa-mapping-querysyntaxexception-foobar-is-not-mapped

업데이트:

댓글남기기