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个回答

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 年之前 回复
zcxgz362324
zcxgz362324   2016.01.21 10:57

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

enpterexpress
enpterexpress   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币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!