IT/Java
[JPA] ConverterNotFoundException: No converter found capable of converting from type 에러
성준하이
2024. 2. 12. 11:04
반응형
native query 사용 중
select 결과에 대한 조회를 해와야하는데
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type
이런 오류를 만났다.
찾아보니 매핑이 정상적으로 이루어지지 않은 문제였고,
dto/entity 를 class가 아닌 interface로 생성하니 해결 되었다.
AsIs
@Data public class TestDto { String id; String name; ... } |
ToBe
@Data public interface TestDto { String getId(); String getName(); ... } |
주의점
Dto 를 사용할 경우 Snake Case 를 자동으로 Camel Case로 인식을 해주는데
interface를 사용하니 매핑이 안되었고, Alias 를 통해서 Camel Case로 직접 명시해주니 매핑이 되었다.
반응형