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 ...
最新文章
- linux 毫秒 转换方法,linux-将抖动转换为毫秒
- 系统集成项目管理之项目采购管理
- 2018/7/16-纪中某C组题【jzoj4024,jzoj4025,jzoj2136,jzoj2137】
- mac安装vue-cli脚手架;脚手架安装报错Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules
- gcc、clang、make、cmake、makefile、CMakeLists.txt概念学习
- 七、区块链如何运用merkle tree验证交易真实性
- dedecms 后台 菜单点击后打开的慢
- java根据wait,notify,synchronize关键字自定义队列
- poj 1129 也算是遍历的吧 两种方法
- 为什么有人说“穷人玩股票一般都会赔”?
- js Indexof的用法
- 正则表达式基础---转自 Python正则表达式指南 前边
- EDG 官宣 Clearlove(明凯)正式退役成为教练,你有什么想说的?
- ubuntu下NS2+leach算法安装笔记(1)
- [免费专栏] ATTACK安全之Android ICMP隧道攻击原理与入侵检测实践
- 泛微平台ecology8.0二进制文件流下载对接接口
- 框架设计--第十七章	SSM框架整合--习题答案
- 计算机表格数字怎么,电脑表格数字打不出来
- mysql报错1194_ERROR 1194 (HY000): Table 't1' is marked as crashed and should be repaired
- Modifier private is redundant for enum constructor
热门文章
- 如何设计二进制文件格式
- Java总结六:面向对象编程(上)
- xshell开启终端256色(转)
- WINDOWS时间服务启动失败的原因
- 教育计算机教育故事初中,信息技术教育教学小故事
- Flash Socket编程
- 创建SDE企业级数据库——在 Oracle 中配置 extproc 以访问 ST_Geometry
- ios10.2重新安装cydia(包含恢复数据库)
- 设置计算机的启动顺序CDROM.C.A,bios如何设置光驱启动顺序?三种BIOS设置光驱第一启动的方法详细图解...
- python3大器----装饰器,迭代器,生成器