导入:
后台日常开发中查询最多,故每次的返回结果就会碰到,有resultMap和resultType,日常有四种情形:


//实体类Dept与表字段不匹配
Dept dept=deptService.selectDept(String id)--><select id="selectDept" resultMap="DeptResult">
//实体类Dept与表字段不匹配
List<Dept> lists=deptService.selectDept(String id)--><select id="selectDept" resultMap="DeptResult">
//实体类Role与表字段匹配
List<Role> lists=roleService.selectRole(String id)--><select id="selectRole" resultType="com....Role">
//实体类Role与表字段匹配
List<Map> lists=roleService.selectRole(String id)--><select id="selectRole" resultType="java.util.Map" >

定义:
resultMap: 实体类字段和表字段不匹配
resultType: 实体类字段和表字段匹配

举例:

resultMap使用:

//实体类
@Data
@AllArgsConstructor
@ToString
public class User implements Serializable{private String userId;private String userName;
}//impl调用
List<User> userList=userService.selectUserList(id)//mapper.xml
<resultMap type="com.....User" id="UserResult"><result property="userId"    column="st_user_id"    /><result property="userName"    column="st_user_name"    /></resultMap><select id="selectUserList" resultMap="UserResult">
select st_user_id, st_user_name
from user
where 1=1
</select>

resultType使用:

//实体类
@Data
@AllArgsConstructor
@ToString
public class User implements Serializable{private String userId;private String userName;
}//impl调用
List<User> userList=userService.selectUserList(id)//mapper.xml
<select id="selectUserList" resultType="com....User">
select st_user_id userId, st_user_name userName
from user
where 1=1
</select>

本文只是笔记

resultMap和resultType区别相关推荐

  1. resultMap和resultType区别详解

    resultMap和resultType区别详解 resultmap与resulttype的区别为:对象不同.描述不同.类型适用不同 一.对象不同 1.resultmap:resultMap如果查询出 ...

  2. mybatis中resultMap和resultType区别,三分钟读懂

    先说结论: resultmap与resulttype的区别为:对象不同.描述不同.类型适用不同. 说人话就是,resultmap和resulttype功能差不多,但是resultmap功能更强大 re ...

  3. mybatis Resultmap 与 ResultType 区别

    Resultmap 的写法====目的是为了做映射 <resultMap id="BaseResultMap"type="com.suning.jupiter.co ...

  4. MyBatis3系列__05查询补充resultMap与resultType区别

    1.查询补充 当你查询一条记录并且是简单查询时,情况相对简单,可以参考以下的例子: public Employee getEmpById(Integer id); 对应的xml文件中: <sel ...

  5. MyBatis学习总结(13)——Mybatis查询之resultMap和resultType区别

    MyBatis的每一个查询映射的返回类型都是ResultMap,只是当我们提供的返回类型属性是resultType的时候,MyBatis对自动的给我们把对应的值赋给resultType所指定对象的属性 ...

  6. MyBatis学习总结_Mybatis查询之resultMap和resultType区别

    MyBatis的每一个查询映射的返回类型都是ResultMap,只是当我们提供的返回类型属性是resultType的时候,MyBatis对自动的给我们把对应的值赋给resultType所指定对象的属性 ...

  7. MyBatis学习总结_13_Mybatis查询之resultMap和resultType区别

    MyBatis的每一个查询映射的返回类型都是ResultMap,只是当我们提供的返回类型属性是resultType的时候,MyBatis对自动的给我们把对应的值赋给resultType所指定对象的属性 ...

  8. mybatis中的resultMap与resultType、parameterMap与 parameterType的区别

    Map:映射:Type:Java类型 resultMap 与 resultType.parameterMap 与  parameterType的区别在面试的时候被问到的几率非常高,项目中出现了一个小b ...

  9. resultMap与resultType、parameterMap与 parameterType的区别

    原文地址:http://blog.csdn.net/csdn_terence/article/details/60779889 Map:映射:Type:Java类型  resultMap 与 resu ...

最新文章

  1. 2018前端常见问题整理
  2. 15-07-15 数据库基础
  3. javaEE开发问题整理(1)
  4. Bootstrap中实现图片圆角效果
  5. Linux时间函数札记
  6. C#实现文件与二进制互转并存入数据库
  7. 前端开发-认识前端开发-0226
  8. 在脚本中, 使用sqlite3检查android程序生成的数据库是否OK
  9. docker 安装 MySQL 8,并减少内存占用 记录
  10. jsp dbbean mysql_Servlet+JSP+MySQL实现用户管理模块之二、实现用户注册
  11. Windows 7 下 PHP 开发环境搭建(手动)
  12. ubuntu16.04安装tomcat7
  13. p5.js 入门教程
  14. Signature Pad 使用
  15. html5在线编辑器效果和源码
  16. Networkx如何画点图并显示边权
  17. Python基础之数据类型II
  18. DAS\NAS\SAN\IPSAN区别
  19. Android中的加密方法
  20. RateLimiter配合ConcurrentHashMap对用户进行简单限流

热门文章

  1. STM32学习笔记:读写内部Flash(介绍+附代码)
  2. wps模板服务器无响应,WPS表格无响应
  3. 福布斯公布2010年富豪榜
  4. 利用Android Studio实现的简单房贷计算器
  5. linux中文入门,Ylmf OS 4.0 - 最适合国人使用和入门学习的中文Linux操作系统 (免费开源)...
  6. 微信企业号开发:微信考勤百度地图定位,错误修正二
  7. linux搭建vds超级节点,VDS | 超级节点搭建流程
  8. frozenui 移动端 搜索框
  9. IOS开发系列之阿堂教程:构建开发IOS应用的虚拟机开发环境实践
  10. 企业如何搞好网络舆情公关?盘点网络舆情优化的方法