[STS] 오류 해결; select문의 resultType

안아현·2024년 9월 11일

Spring

목록 보기
13/13

It's likely that neither a Result Type nor a Result Map was specified.

위 오류는 mapper.xml에서 select문의 resultType을 지정하지 않아 발생한다.

결과 데이터가 없거나 그 값이 정수인 write, update, delete와 다른 양상을 보이는 select문은 resultType을 지정할 필요가 있다.
따라서 mapper.xml에서 select문의 resultType을 지정하지 않으면 오류가 발생한다. 이때 지정하는 resultTYPE은 mapper interface에서 추상메서드를 선언할 때 사용한 데이터 타입과 동일해야 한다.

<select id="getTotalRow">
		select count(*) from faq where 1=1 <include refid="search"/>
</select>
<!-- 위 코드에 resultType을 추가하면 된다.-->
<select id="getTotalRow" resultType="Long">
		select count(*) from faq where 1=1 <include refid="search"/>
</select>
profile
programming

0개의 댓글