zoukankan      html  css  js  c++  java
  • Result Maps collection does not contain value for

    MyBatis报这个错的原因

    1. BaseResultMap 的问题

    <resultMap id="UserMap" type="com.test.User">
      ...
    </resultMap >
    <select id="selectUser" resultMap="UserMaper">
      ...
    </select>

    resultMap标签 的id 是 UserMap 而select 的resultMap要和上边的 id 属性值统一名字

    2. <resultMap> 标签里面的字段和 type属性实体类的对不上,不管是少了还是类型对不上之类的,解决办法就是检查字段映射

    3.用resultMap返回其他类型

    <select id="selectUser" resultMap="com.ssm.study.entity.User"> 
      ...
    </select>
    <select id="selectUser" resultType="com.ssm.study.entity.User">
      ...
    </select>

    第一个会报错、第二个是正确的

    就是把resultMap和resultType搞混了 ,resultMap只能返回实体映射<resultMap>

    返回其他类型 如:com.ssm.study.entity.User 就使用 resultType

     

  • 相关阅读:
    二维空间轨迹聚类
    Java 格式化输出
    Linux 小笔记
    Nginx ServerName 配置说明(转)
    LVS
    Nginx + tomcat 实现简单集群(基于反向代理方式)
    mysql 外键
    tomcat 日志输出
    tomcat https
    SpringMVC表单标签简介
  • 原文地址:https://www.cnblogs.com/dsds/p/15699285.html
Copyright © 2011-2022 走看看