问题描述
- 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""> idtranstypeopeniddeveloperopenidchargermsisdnpartnertransactionidtradenototal_feeproduct_feediscountpar_valuesubscribeappidstatusresultcreatetime</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(transtypeopeniddeveloperopenidchargermsisdnpartnertransactionidtradenototalfeeproductfeediscountparvaluesubscribeappidstatusresultcfromcreatetime) 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如下:
实在是找不到那里又问题啊
解决方案
看看是不是你没定义好。 http://blog.csdn.net/gjswxhb/article/details/23390365
解决方案二:
你前面定义的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才是后面引用属性的值。
解决方案三:
修改: 将resultMap=""RechargeBean"" 改为 resultMap=""rechargeResult"" 。采纳,给分,对mybatis还不熟悉呀
解决方案四:
Could not find result map
解决方案五:
结果集映射出错,你没有配置号resultMap
时间: 2024-09-23 07:39:58