개발/Datebase
MyBatis 매퍼 오류
aihtnyc_h
2024. 11. 3. 16:10
728x90
반응형
SMALL
### 에러 노트: MyBatis 매퍼 오류
#### 문제 설명
- **에러 메시지**:
`ERROR 24-10-29 08:29:14[http-nio-8089-exec-2]
[[dispatcherServlet]:175] - Servlet.service() for servlet
[dispatcherServlet] in context with path [] threw exception
[Request processing failed; nested exception is org.apache.ibatis.binding.BindingException:
Mapper method 'mdt.restapi.cohttp://m.mobile.mapper.PaymentMapper.updateAccumlatedCharges'
has an unsupported return type: class mdt.restapi.cohttp://m.mobile.model.PaymentModel]
with root cause`
- **원인**: MyBatis에서 정의한 `updateAccumlatedCharges` 메소드의 반환 타입이 `PaymentModel`로 설정되어 있지만, 이는 지원되지 않는 타입이라는 오류입니다.
#### 발생 상황
업데이트 쿼리를 수행하는 메소드에서 일반적으로 반환값이 필요 없거나, 업데이트된 행의 수를 반환하는 경우가 많습니다. 현재 메소드의 반환 타입이 `PaymentModel`로 설정되어 있어 MyBatis에서 처리할 수 없습니다.
#### 해결 방안
- 반환 타입을 `int`로 변경하여 업데이트된 행의 수를 반환하도록 수정해야 합니다.
int updateAccumlatedCharges(PaymentModel paymentModel);
<update id="updateAccumlatedCharges" parameterType="mdt.restapi.cohttp://m.mobile.model.PaymentModel">
UPDATE tb_accumulated_charges ch
SET ch.accumulated_amount = #{remainPrice} + ch.accumulated_amount
WHERE token_id = #{tokenId};
</update>
728x90
반응형
LIST