导入:
后台日常开发中查询最多,故每次的返回结果就会碰到,有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. linux 毫秒 转换方法,linux-将抖动转换为毫秒
  2. 系统集成项目管理之项目采购管理
  3. 2018/7/16-纪中某C组题【jzoj4024,jzoj4025,jzoj2136,jzoj2137】
  4. mac安装vue-cli脚手架;脚手架安装报错Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules
  5. gcc、clang、make、cmake、makefile、CMakeLists.txt概念学习
  6. 七、区块链如何运用merkle tree验证交易真实性
  7. dedecms 后台 菜单点击后打开的慢
  8. java根据wait,notify,synchronize关键字自定义队列
  9. poj 1129 也算是遍历的吧 两种方法
  10. 为什么有人说“穷人玩股票一般都会赔”?
  11. js Indexof的用法
  12. 正则表达式基础---转自 Python正则表达式指南 前边
  13. EDG 官宣 Clearlove(明凯)正式退役成为教练,你有什么想说的?
  14. ubuntu下NS2+leach算法安装笔记(1)
  15. [免费专栏] ATTACK安全之Android ICMP隧道攻击原理与入侵检测实践
  16. 泛微平台ecology8.0二进制文件流下载对接接口
  17. 框架设计--第十七章 SSM框架整合--习题答案
  18. 计算机表格数字怎么,电脑表格数字打不出来
  19. mysql报错1194_ERROR 1194 (HY000): Table 't1' is marked as crashed and should be repaired
  20. Modifier private is redundant for enum constructor

热门文章

  1. 如何设计二进制文件格式
  2. Java总结六:面向对象编程(上)
  3. xshell开启终端256色(转)
  4. WINDOWS时间服务启动失败的原因
  5. 教育计算机教育故事初中,信息技术教育教学小故事
  6. Flash Socket编程
  7. 创建SDE企业级数据库——在 Oracle 中配置 extproc 以访问 ST_Geometry
  8. ios10.2重新安装cydia(包含恢复数据库)
  9. 设置计算机的启动顺序CDROM.C.A,bios如何设置光驱启动顺序?三种BIOS设置光驱第一启动的方法详细图解...
  10. python3大器----装饰器,迭代器,生成器