resultMap和resultType区别
导入:
后台日常开发中查询最多,故每次的返回结果就会碰到,有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区别相关推荐
- resultMap和resultType区别详解
resultMap和resultType区别详解 resultmap与resulttype的区别为:对象不同.描述不同.类型适用不同 一.对象不同 1.resultmap:resultMap如果查询出 ...
- mybatis中resultMap和resultType区别,三分钟读懂
先说结论: resultmap与resulttype的区别为:对象不同.描述不同.类型适用不同. 说人话就是,resultmap和resulttype功能差不多,但是resultmap功能更强大 re ...
- mybatis Resultmap 与 ResultType 区别
Resultmap 的写法====目的是为了做映射 <resultMap id="BaseResultMap"type="com.suning.jupiter.co ...
- MyBatis3系列__05查询补充resultMap与resultType区别
1.查询补充 当你查询一条记录并且是简单查询时,情况相对简单,可以参考以下的例子: public Employee getEmpById(Integer id); 对应的xml文件中: <sel ...
- MyBatis学习总结(13)——Mybatis查询之resultMap和resultType区别
MyBatis的每一个查询映射的返回类型都是ResultMap,只是当我们提供的返回类型属性是resultType的时候,MyBatis对自动的给我们把对应的值赋给resultType所指定对象的属性 ...
- MyBatis学习总结_Mybatis查询之resultMap和resultType区别
MyBatis的每一个查询映射的返回类型都是ResultMap,只是当我们提供的返回类型属性是resultType的时候,MyBatis对自动的给我们把对应的值赋给resultType所指定对象的属性 ...
- MyBatis学习总结_13_Mybatis查询之resultMap和resultType区别
MyBatis的每一个查询映射的返回类型都是ResultMap,只是当我们提供的返回类型属性是resultType的时候,MyBatis对自动的给我们把对应的值赋给resultType所指定对象的属性 ...
- mybatis中的resultMap与resultType、parameterMap与 parameterType的区别
Map:映射:Type:Java类型 resultMap 与 resultType.parameterMap 与 parameterType的区别在面试的时候被问到的几率非常高,项目中出现了一个小b ...
- resultMap与resultType、parameterMap与 parameterType的区别
原文地址:http://blog.csdn.net/csdn_terence/article/details/60779889 Map:映射:Type:Java类型 resultMap 与 resu ...
最新文章
- 2018前端常见问题整理
- 15-07-15 数据库基础
- javaEE开发问题整理(1)
- Bootstrap中实现图片圆角效果
- Linux时间函数札记
- C#实现文件与二进制互转并存入数据库
- 前端开发-认识前端开发-0226
- 在脚本中, 使用sqlite3检查android程序生成的数据库是否OK
- docker 安装 MySQL 8,并减少内存占用 记录
- jsp dbbean mysql_Servlet+JSP+MySQL实现用户管理模块之二、实现用户注册
- Windows 7 下 PHP 开发环境搭建(手动)
- ubuntu16.04安装tomcat7
- p5.js 入门教程
- Signature Pad 使用
- html5在线编辑器效果和源码
- Networkx如何画点图并显示边权
- Python基础之数据类型II
- DAS\NAS\SAN\IPSAN区别
- Android中的加密方法
- RateLimiter配合ConcurrentHashMap对用户进行简单限流
热门文章
- STM32学习笔记:读写内部Flash(介绍+附代码)
- wps模板服务器无响应,WPS表格无响应
- 福布斯公布2010年富豪榜
- 利用Android Studio实现的简单房贷计算器
- linux中文入门,Ylmf OS 4.0 - 最适合国人使用和入门学习的中文Linux操作系统 (免费开源)...
- 微信企业号开发:微信考勤百度地图定位,错误修正二
- linux搭建vds超级节点,VDS | 超级节点搭建流程
- frozenui 移动端 搜索框
- IOS开发系列之阿堂教程:构建开发IOS应用的虚拟机开发环境实践
- 企业如何搞好网络舆情公关?盘点网络舆情优化的方法