Query_syntax_exception: foo is not mapped
“QuerySyntaxException: posts is not mapped…”
테스트 코드를 돌리니 위와 같은 에러가 났다.
구글링을 하니 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
댓글남기기