在做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. HTML5 data-* 自定义属性操作及其注意点

    在HTML5中添加了data-*的方式来自定义属性,所谓data-*实际上上就是data-前缀加上自定义的属性名,命名可以用驼峰命名方式,但取值是必需全部使用小写(后面会说),使用这样的结构可以进行数 ...

  2. 分析一点python源代码

    偶然看了一下python的部分源代码,感觉python的作者写的代码真心很美,简洁美观,学习之. 举几个例子抛砖引玉一下: def removedirs(name): ""&quo ...

  3. Linux命令之文件重定向2

    linux中重定向用符号“>”表示,语法一般是 源文件 > 目标文件 1)创出.txt文件touch 1.txt 注意:创建文件夹用mkdir 2)向.txt文件中写入内容 注意:①cat ...

  4. CentOS 7.0 各版本下载说明 新增Everything版

    CentOS-7.0-1406有很多可供选择的版本,对初学者来说,不知如何选择,下面做简单的介绍: CentOS-7.0-1406-x86_64-DVD.iso 标准安装版,一般下载这个就可以了 Ce ...

  5. SINAMICS S120 Parking axis设置,安转拆除或屏蔽电机

    1) P897 Parking axis selection 此参数可以连接到周期通讯的报文中(PZD) 2) 标准报文111中,已经连接此参数

  6. 如何将位置值写入simotion encoder?

    目标: 将变量值(任意实数)写入Encoder,作为encoder的实际位置值.例如,将MP177手轮的值写入编码器,达到SMC30配置手轮的功能. Platform: simotion D435-2 ...

  7. vue 中$index $key 已经移除了

    https://cn.vuejs.org/v2/guide/migration.html#index-and-key-移除 之前可以这样: 1 2 3 4 5 6 <ul id="ex ...

  8. JavaEE权限管理系统的搭建(三)--------springmvc和mabatis整合环境搭建

    本节介绍如何环境的搭建和配置: 首先要在父工程引入jar包依赖: <!-- 通过属性定义指定jar的版本 --> <properties> <spring.version ...

  9. React后端管理系统-商品详情detail组件

    import React from 'react'; import MUtil from 'util/mm.jsx' import Product from 'service/product-serv ...

  10. 知识总结和记录——HTML

    文档结构 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="U ...