티스토리 뷰

오늘 한 일

 

오늘 Repository에서 Query문을 작성하다 아래와 같은 에러가 발생했다.

No converter found capable of converting from type 

 

Query를 데이터로 어떻게 받아와야 하는지 고민하는데 하루의 절반을 사용하였다.

 

알아낸 결과 쿼리문에서 select한 값에 AS로 클래스 변수명을 지목해서 반환한다.
또한 Dto를 인터페이스 형식으로 만들어서 select된 데이터 반환값을 매핑시켜 준다.

 

   @Query(
        nativeQuery = true,
        value = "SELECT rc.recruitment_id AS recruitmentId, rc.content AS content "
            + "FROM recruitment_comment rc JOIN recruitment r on rc.recruitment_id = r.id "
            + "where rc.user_id = :userId"
    )
    Page<RecruitmentCommentsDto> findMyPageRecruitmentComments(Pageable pageable,
        @Param("userId") Long userId);
public interface RecruitmentCommentsDto {

    Long getRecruitmentId();

    String getContent();

}

 

 

배운점 

 

개발자는 오류를 해결하기 위해 고민하면서 성장하는 것 같다.

 

 

 

 

 

 

 

 

'개발 > Today I Learned' 카테고리의 다른 글

TIL 23-02-28 #백그라운드 잡  (0) 2023.02.28
TIL 23-02-23 #Oauth2  (0) 2023.02.23
TIL 23-02-14 # @Param  (0) 2023.02.15
TIL 23-02-09 #크롤링(2)  (0) 2023.02.11
TIL 23-02-08 #Jsoup, Selenium 크롤링  (0) 2023.02.09
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/11   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
글 보관함