🏕️상황
ConverterNotFoundException: No converter found capable of converting from type [hanium.highwayspring.school.Curriculum.Curriculum] to type [java.lang.String]] with root cause org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [hanium.highwayspring.school.Curriculum.Curriculum] to type [java.lang.String] at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericCon
이러한 오류가 발생하여 가장 먼저 의심한 곳은
" DTO를 사용하지 않고, 직접 entity를 사용해서 그런가?" 하는 생각이 들었다.
그런 생각이 든 이유는.... 아래의 블로그에서 작성했을 때가 기억이 났다. DTO를 사용해서 저런 converter 오류를 해결해 본 경험이 있기 때문이다~~
https://grogrammer.tistory.com/21
[개발]🚨ERROR - org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error
🛤️상황 @RestController @CrossOrigin(origins = "http://localhost:3000", methods = {RequestMethod.OPTIONS, RequestMethod.DELETE, RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT}) @RequestMapping("/review") public class ReviewController { priv
grogrammer.tistory.com
💦과정
하지만 DTO로는 해결될 기미가 보이지 않았고, converter 관련 클래스를 만들어서 그것까지 활용해 보았지만 여전히 실패..... 답답해서 미칠 때쯤에, 곰곰이 생각해 보니 이런 생각이 들었다.
해당 오류는 뭔가 '변환'에 실패했다는 것인데.. 그럼 실제 메서드의 반환 값과
메소드의 반환값이 달라서 '변환'에 실패한 것이 아닐까?
🗝️해결

위의 방식처럼 데이터를 다룰 때에는 DTO를 활용하고자 저런 방식을 사용했는데... 알아보니
jpa 메서드를 활용할 때는 엔티티를 조회하는 것이 일반적이며,
DTO를 활용해서 메소드를 정의하는 것은 일반적이지 않다고 한다.
엔티티를 직접 조회하는 것이 더 효율적이며, DTO로 조회하고 싶다면 엔티티로 조회를 한 후에 DTO로 변환하는 작업은 따로 진행하는 것이 좋다.
DTO는 주로 데이터 전송을 위한 용도로 사용하는 것이다.
