在做mybatis多表查询的时候,出现了下面的错误:

java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.up.sell.mapper.system.AdvertisementMapper.areasResult
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:888) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.session.Configuration.getResultMap(Configuration.java:640) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getNestedResultMap(DefaultResultSetHandler.java:1011) ~[mybatis-3.4.6.jar:3.4.6]
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyNestedResultMappings(DefaultResultSetHandler.java:945) ~[mybatis-3.4.6.jar:3.4.6]

意思很明确,是ResultMap映射出现了问题,下面贴上映射代码:

    <resultMap type="Advertisement" id="AdvertisementResult">
<id property="id" column="id" />
<result property="title" column="title" />
<result property="imgPath" column="img_path" />
<result property="url" column="url" />
<result property="description" column="description" />
<result property="sorrt" column="sorrt" />
<result property="place" column="place" />
<result property="provinceId" column="province_id" />
<result property="cityId" column="city_id" />
<result property="advFlag" column="adv_flag" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="updateUser" column="update_user" />
<result property="updateTime" column="update_time" />
<association property="provinceId" column="id" javaType="Areas" resultMap="areasResult"/>
</resultMap>

我的sql代码:

    <select id="findList" parameterType="Advertisement" resultMap="AdvertisementResult">
SELECT
a.id ,
a.title ,
a.img_path ,
a.url ,
a.description ,
a.sort ,
s.area_name ,
s1.short_name
FROM
advertisement a
LEFT JOIN areas s ON
a.province_id = s.id LEFT JOIN areas s1 on a.city_id
= s1.id
</select>

我是把关联表的resultMap忘记写了,加上之后就好了,代码如下:

    <resultMap id="areasResult" type="Areas">
<id property="id" column="id" />
<result property="areaName" column="area_name" />
<result property="parentId" column="parent_id" />
<result property="shortName" column="short_name" />
</resultMap>

主表的resultMap和副表的resuleMap Id是对应的。

Result Maps collection does not contain value for XXXXX的更多相关文章

  1. java.lang.IllegalArgumentException: Result Maps collection does not contain value for java.lang.Integer

    今天做springmvc+mybatis+spring的项目的时候发现了一个异常.如下: org.apache.ibatis.builder.IncompleteElementException: C ...

  2. Result Maps collection already contains value for

    Result Maps collection already contains value for select s.id,s.branch_name from t_wx_shop s left jo ...

  3. mybatisGenerator 代码自动生成报错 Result Maps collection already contains value for BaseResultMap--转

    转自:http://blog.csdn.net/tan3739/article/details/7555665 Exception in thread "main" Java.la ...

  4. nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoSupport': ...

  5. mybatis Result Maps collection already contains value for com.ebways.dictionary.dao.impl.PtInfoDaoImpl.beanMap

    java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.conte ...

  6. MyBatis出错Result Maps collection does not contain value for java.lang.Integer

    Servlet.service() for servlet [SpringMVC] in context with path [/eyou] threw exception [Request proc ...

  7. mybatisGenerator 代码自动生成报错 Result Maps collection already contains value for BaseResultMap【转】

    由于mybatis简单易学,比起Hibername来,更容易上手,代码也能自动生成.这几天研究了下代码自动生成的,参考: http://0609xiaohua.iteye.com/blog/14535 ...

  8. java.lang.IllegalArgumentException: Result Maps collection already contains value for

    如果在SSM整合的时候出现以下的错误: 留意一下是不是既在Mybatis配置文件中加载了映射文件,又在Spring配置文件中使用扫描式去加载映射文件了.两者是不能够重合使用的! Caused by: ...

  9. mybatis 异常Result Maps collection does not contain value for java.lang.String

    Result Maps collection does not contain value for java.lang.String 以上是我报的错. 只要报Result Maps collectio ...

随机推荐

  1. Can't connect to any repository.Read timed out after 30,000 ms

    解决方法:

  2. Vim中根据正则对选中文本对齐(比如ini文件的=号对齐)

    vimrc增加如下内容即可: vnoremap <M-=> :call Duiqi('\v(^\s*\S+)\s+(.*)')<CR> "reg匹配的第2段文字对齐 ...

  3. 笨办法学Python(二十七)

    习题 27: 记住逻辑关系 到此为止你已经学会了读写文件,命令行处理,以及很多 Python 数学运算功能.今天,你将要开始学习逻辑了.你要学习的不是研究院里的高深逻辑理论,只是程序员每天都用到的让程 ...

  4. 笨办法学Python(二十二)

    习题 22: 到现在你学到了哪些东西? 这节以及下一节的习题中不会有任何代码,所以也不会有习题答案或者加分习题.其实这节习题可以说是一个巨型的加分习题.我将让你完成一个表格,让你回顾你到现在学到的所有 ...

  5. RF脚本中的坑1: SyntaxError: invalid token

    话不多说,直接上调试脚本: 执行后${b}=8:没问题.然后${a}改成08继续: 执行后居然报错了: 经过多次尝试08或者09时,都会报SyntaxError错误:后来查阅语法,才恍然大悟:Pyth ...

  6. IOS 拉伸图片(封装)

    /** * 根据图片名返回一张能够自由拉伸的图片 */ +(UIImage *)resizedImage:(NSString *)name { UIImage *image=[UIImage imag ...

  7. Linux空间PHP开发环境小白教程(LAMP)

    租了一个云服务器, 但是只有linux系统,没有php开发环境, 只好自己摸索着一步一步安装啦. 本教程来自自学IT创E老师的Linux教程,想详细了解的可以去论坛找. 一.使用PUTTY登录服务器 ...

  8. 正定矩阵(Positive-definite Matrix)

    原文链接 正定矩阵是自共轭矩阵的一种.正定矩阵类似复数中的正实数.定义:对于对称矩阵M,当且仅当存在任意向量x,都有 若上式大于等于零,则称M为半正定矩阵.正定矩阵记为M>0.也被称为正定二次型 ...

  9. 前端小记4——高性能mobile web开发

    1.高性能CSS3动画 与PC端场景需要相比,移动web端需要考虑的因素也相对复杂,重点考虑:流量.功耗与流畅度.在pc端上考虑更多的是流畅度,而mobile web中需要考虑网络流量的使用和耗电情况 ...

  10. 简单webservice实现(xFire1.2)

    基于xfire实现webservice的实例 首先下载xfire的jar包,并导入项目当中 下载地址:http://xfire.codehaus.org/Download 编写实现类 首先建一个接口把 ...