이슈내용
group_concat을 사용해서 결과값을 리스트로 조회해오는 mybatis 쿼리에서 아래와 같은 에러가 발생했다.
java.lang.UnsupportedOperationException
원인
해당 오류는 mapper 인터페이스의 리턴 타입과 xml의 구현체의 resultType이 일치하지 않아서 발생한 오류로,
Mapper 인터페이스에는 아래와 같이 List 형태로 받게 지정해놨는데, xml의 쿼리 resultType으로 String 타입이 아닌 list라고 지정한 것이 원인이었다.
mybatis에서 리턴값을 List로 받기 위해서는 resultType에는 기본형타입만 지정하고, mapper 인터페이스 부분에 리턴값으로 List<> 형태를 지정해야 한다!
✅ Mapper
✅ XML
해결방안
아래와같이 resultType을 String 형태으로 지정해서 오류를 해결했다.
'Trouble Shooting > MyBatis' 카테고리의 다른 글
[Mybatis] #{} 문법에 주석 처리시 오류 해결 (0) | 2023.05.02 |
---|---|
[Mybatis] choose문 when 절 문자열 비교 실패하는 이슈 해결 (0) | 2022.07.20 |
[Mybatis] IF문 공백 체크 시 int형 파라미터를 null로 인식하는 이슈 (0) | 2022.07.20 |