org.apache.ibatis.binding.BindingException: Mapper method 'com... has an unsupported return type

场景:

service中间调用dao层方法时,出现以下错误,但是sql执行修改数据成功,并没有回滚问题:

十月 31, 2017 2:53:39 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [bigaoread] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Mapper method 'com.bigaoread.platform.dao.beautifulreader.v2.YzActivecontrolMapper.updateActiveId' has an unsupported return type: class com.bigaoread.platform.model.beautifulreader.v2.YzActivecontrol] with root cause
org.apache.ibatis.binding.BindingException: Mapper method 'com.bigaoread.platform.dao.beautifulreader.v2.YzActivecontrolMapper.updateActiveId' has an unsupported return type: class com.bigaoread.platform.model.beautifulreader.v2.YzActivecontrol
	at org.apache.ibatis.binding.MapperMethod.rowCountResult(MapperMethod.java:91)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:54)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
	at com.sun.proxy.$Proxy41.updateActiveId(Unknown Source)


原因:这个是因为dao层的sql执行成功后,返回的类型出现问题。

代码:

service层:

	public Map<String, Object> updateActiveId(String newActiveId, String oldActiveId) {
		Map<String, Object> resultMap = new HashMap<>();
		if(subscribeQrcodeService.isExistActiveId(Long.parseLong(newActiveId))) {
			resultMap.put("status", 1);
			return resultMap;
		}
		if(!(null == this.get(Long.parseLong(newActiveId)))) {
			resultMap.put("status", 1);
			return resultMap;
		}
		Map<String, Object> updateIdMap = new HashMap<>();
		updateIdMap.put("newActiveId", Long.parseLong(newActiveId));
		updateIdMap.put("oldActiveId", Long.parseLong(oldActiveId));
		yzActivecontrolMapper.updateActiveId(updateIdMap);
		resultMap.put("status", 0);
		return resultMap;
	}
dao层:

YzActivecontrol updateActiveId(Map<String, Object> updateIdMap);

mapper.xml:

    <update id="updateActiveId" parameterType="Map">
    	UPDATE <include refid="tableName"/>
    	SET id = #{newActiveId}
    	WHERE id = #{oldActiveId}
    </update>


解决:

mapper文件中的update,delete,insert语句是不需要设置返回类型的,它们都是默认返回一个int,所以应该修改dao层接口的方法:

Integer updateActiveId(Map<String, Object> updateIdMap);
或者

void updateActiveId(Map<String, Object> updateIdMap);






  • 30
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 11
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值