JPQL로 신나게 두들기다 다음과 같은 오류가 났습니다...
그리고 이는 문제의 코드 입니다.
@Query(value = "select r from Report r " +
"where ST_Dwithin(r.location, :point, :radius, false) = true")
List<Report> findReportsWithinRadius(@Param("point") Point point, @Param("radius") double radius);
구글링을 해보니 nativeQuery = true 조건을 걸어주면 된다고 합니다...
@Query(value = "select r from Report r " +
"where ST_Dwithin(r.location, :point, :radius, false) = true", nativeQuery = true)
List<Report> findReportsWithinRadius(@Param("point") Point point, @Param("radius") double radius);
그러나 여전히 드는 의문점은 nativeQuery 조건은 진짜 날 것 그 자체의 쿼리를 사용할때 쓰는 조건이라 알고 있는데...
저는 분명 JPQL을 사용했는데 왜 nativeQuery 조건을 주고 또 왜 올바르게 돌아가는 것인지는 모르겠습니다...ㅠㅠ
수정
분명 JPQL을 사용하지만 nativeQuery = true 조건을 달면 위의 에러는 사라집니다. 또한 다음과 같은 그럴듯한 에러가 발생합니다.
그리고 이를 해결하기 위한 방법으로는 애초부터 JPQL + nativeQuery = true 조건을 달아서 사용하는 것이 아닌 nativeQuery + nativeQuery = true로 해주면 됩니다.
아래는 수정한 native Query입니다.
@Query(value = "SELECT * FROM Report r " +
"WHERE ST_DWithin(r.location, :point, :radius, false) = true", nativeQuery = true)
List<Report> findReportsWithinRadius(@Param("point") Point point, @Param("radius") double radius);
'오류일기' 카테고리의 다른 글
Docker로 H2 컨테이너로 띄우기(포트 문제) (0) | 2024.04.06 |
---|---|
nGrinder java.io.tmpdir 오류 해결방법 (0) | 2024.04.03 |
[JPA] PostgreSQL을 사용하는 환경에서 Point 타입 사용하기 (1) | 2024.01.27 |
Google Cloud Storage + Spring Boot 401 Unauthorized (0) | 2024.01.22 |
[Spring Boot] MockMvc를 이용해 파일과 제이슨 형태를 한번에 받는 메소드 테스트하기 (0) | 2024.01.21 |