2 enxiaowei0 enxiaowei0 于 2016.01.21 10:06 提问

mybatis Could not find result map 5C

异常如下:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.IncompleteElementException: Could not find result map com.unisk.weixin.js.pay.dao.RechargeOrderMapper.RechargeBean
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
at com.sun.proxy.$Proxy5.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:240)
at com.unisk.weixin.js.pay.dao.impl.PayOrderMapperImpl.insertPayOrder(PayOrderMapperImpl.java:25)
at com.unisk.weixin.js.pay.service.impl.OrderServiceImpl.saveOrder(OrderServiceImpl.java:16)
RechargeOrderMapper.xml如下:
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE mapper PUBLIC

"-//mybatis.org//DTD Mapper 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<!--这块等于dao接口的实现 namespace必须和接口的类路径一样-->

<resultMap  type="RechargeBean" id="rechargeResult">  
    <id column="id" property="id"/>  

</resultMap> 
<!-- 用来定义可重用的SQL代码段 -->  
<sql id="recharge_sql">  

 id,transtype,openid,developeropenid,chargermsisdn,partner,transactionid,tradeno,total_fee,product_fee,discount,par_value,subscribe,appid,status,result,createtime
</sql>  

<select id="selectAll" resultMap="rechargeResult">
    select <include refid="recharge_sql"/> from rechargeorder order by createtime desc
</select>
<insert id="insertRechargeOrder" parameterType="RechargeBean" useGeneratedKeys="true" keyProperty="id">
    insert into rechargeorder(transtype,openid,developeropenid,chargermsisdn,partner,transactionid,tradeno,totalfee,productfee,discount,parvalue,subscribe,appid,status,result,cfrom,createtime) values 
    (#{trans_type},#{openid},#{developeropenid},#{charger_msisdn},#{partner},#{transaction_id},#{out_trade_no},#{total_fee},#{product_fee},#{discount},#{par_value},#{issubscribe},#{appid},#{status},#{result},#{from},now())
</insert>
<update id="update" parameterType="RechargeBean">
    update rechargeorder set status=#{status},result=#{result},cfrom=#{from} where tradeno=#{out_trade_no} and transactionid=#{transaction_id}
</update>

<delete id="delete" parameterType="int">
    delete from rechargeorder where id=#{id}
</delete>

<select id="findById" parameterType="int" resultMap="RechargeBean">  
    select <include refid="recharge_sql"/>  from rechargeorder where id = #{id}  
</select> 

 <select id="selectBytradeNo" resultMap="RechargeBean" parameterType="java.util.Map">  
     select <include refid="recharge_sql"/> from rechargeorder WHERE tradeno=#{tradeNo} and openid=#{openId}  
</select> 



configuration.xml如下:







实在是找不到那里又问题啊

6个回答

zcxgz362324
zcxgz362324   2016.01.21 10:57

修改: 将resultMap="RechargeBean" 改为 resultMap="rechargeResult" 。采纳,给分,对mybatis还不熟悉呀

rui888
rui888   Ds   Rxr 2016.01.21 10:17

看看是不是你没定义好。 http://blog.csdn.net/gjswxhb/article/details/23390365

wojiushiwo945you
wojiushiwo945you   Ds   Rxr 2016.01.21 10:23

你前面定义的resultMap的id是rechargeResult,这个名称才是后面的sql语句中的属性resultMap的值。
修正你的查找select中的resultMap值为上面定义的id才对。

 <select id="findById" parameterType="int" resultMap="rechargeResult">  
    select <include refid="recharge_sql"/>  from rechargeorder where id = #{id}  
</select> 

 <select id="selectBytradeNo" resultMap="rechargeResult" parameterType="java.util.Map">  
     select <include refid="recharge_sql"/> from rechargeorder WHERE tradeno=#{tradeNo} and openid=#{openId}  
</select> 

你对resultMap的使用方法还不太明白,前面定义的id才是后面引用属性的值。

BestwishesTolover
BestwishesTolover 这楼说的是对的
2 年多之前 回复
enpterexpress
enpterexpress   Rxr 2016.01.21 11:52
euthan
euthan   2016.01.22 09:20

结果集映射出错,你没有配置号resultMap

FluxMode
FluxMode   2017.08.24 16:50

parameterType 非基本类型需要 配置全路径吧

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
myibatis 报错 Could not find result map java.util.HashMap
mybatis异常:Could not find result map Java.util.Map 问题分析及解决   错误写法   resultMap="java.util.Map" > 正确写法:   resultType="java.util.Map">
mybatis IncompleteElementException:Could not find result map java.lang.String
MyBatis项目中在查询数据库时遇到org.apache.ibatis.builder.IncompleteElementException: Could not find result map java.lang.String。 原因了把resultType="java.lang.String" 写成了 resultMap="java.lang.String" ,就会出错的,注意
mybatis报Could not find result map java.lang.Integer之类的错误
在测试的时候报告:org.apache.ibatis.builder.IncompleteElementException: Could not find result map java.lang.Integer 我检查了对应的mapper文件和接口文件都没有发现问题。运行任何一个和mybatis相关的测试,发现全部都报告这个错误。 我猜想是mybatis的配置文件出错了,检查后发现没有问题。
mybatis报Could not find result map java.lang.String
项目原先跑的是正常的svn更新一下就报:Request processing failed; nested exception is org.apache.ibatis.builder.IncompleteElementException: Could not find result map java.lang.String 都要抓狂了,明明已经测试完了功能模块突然报这个错 找到点击出发的
mybatis错误提示Could not find result map com.sale.entity.User
一、问题描述错误提示org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.IncompleteElementException:Could not find result map com.sale.entity.Usermapper.xml代码: &amp;lt;resultMap ...
mybatis异常:Could not find result map java.util.Map 问题分析及解决
mybatis异常:Could not find result map java.util.Map 问题分析及解决   错误写法   mybatis报出的异常日志: org.apache.ibatis.builder.IncompleteElementException: Could not find result map java.util.Map  at org.apache.i
Spring Boot启动 MyBatis报错 Could not find result map java.lang.Integer
工作的项目,Spring Boot整合Mybatis后启动报错Could not find result map java.lang.Integer。直接拉到最后看到错误信息:Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for java.lang.Integ...
Could not find result map XXX 解决办法
出错代码:<select id="selectByPartName"      resultMap="com.mybatistest.common.QueryBase" parameterType="String"> SELECT * FROM manager WHERE name like CONCAT('%',# {parameters.partName},'%
Mybatis报错:Could not find result map
四月 08, 2018 9:00:19 下午 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() for servlet [SpringMVC] in context with path [/bookclub] threw exception [Request processing failed; ne...
Could not find result map java.util.Map 问题分析及解决
mybatis异常:Could not find result map Java.util.Map 问题分析及解决   错误写法   resultMap="java.util.Map" > mybatis报出的异常日志: org.apache.ibatis.builder.IncompleteElementException: Could not find result map ja