JPA #NativeQuery #JPQL #
-
[JPA] NativeQuery를 POJO로 mapping하기Backend/Springboot 2022. 9. 16. 13:41
JPA Repository에 있는 데이터를 직접 정의한 class에 바로 담기 위해 고군분투를 해보았다. 실제로 Entity 형식이 아닌 다른 형식으로 데이터를 바로 담고 싶을 때가 있었다. 즉 NativeQuery를 활용해 SQL로 가공 및 처리하여 필요한 정보만을 추출해 서버단에서는 가공된 데이터만을 받아서 클라이언트에게 전달하는 역할만 하는 것이 더 효율적이라고 판단했기 때문이다. NativeQuery로 작성한 쿼리를 직접 정의한 class(POJO or DTO)로 불러오기 다음과 같은 에러가 떴다. ConverterNotFoundException org.springframework.core.convert.ConverterNotFoundException: No converter found capab..