MyBatis 에러: no Result Maps were found for the Mapped Statement

2021. 12. 17. 03:06
반응형

A query was run and no Result Maps were found for the Mapped Statement 'xxx.xxx.xxx.mapper.XxxMapper.totalHit'.  It's likely that neither a Result Type nor a Result Map was specified

 

이 에러는

org.apache.ibatis.executor.ExecutorException

마이바티스 에러다

 

mapper에 쿼리문을 써줄 때 resultType을 지정해주지 않으면 나는 에러.

지정해주지 않아도 잘 될 때도 있는데 이건 왜 이런지 모르겠다

 

그래서 resultMap을 지정해준다면 어떻게 되는가!

attempted to return null from a method with a primitive return type (int).

라는 에러가 난다.

 

totalHit 라는 함수는 내가 작성한 쿼리인

select sum(bd_count)
from book_detail
where book_bd_idx = #{book_idx}

이고 분명히 책 페이지 테이블에서 책번호로 카운트의 합계도 잘 구해진다

book_idx는 DB에서 int타입이라 Integer로 변수를 넣어주었고

sum(bd_count)가 반환될 때 혹시 int거나 해서 에러가 나나 싶어서 메소드 리턴타입을 Integer로 바꿔주기도 해 보았는데 결과는 attempted to return null from a method with a primitive return type (int).

count값이 숫자로 반환되는데 어째서 null이란 말이냐...?

반응형

BELATED ARTICLES

more