当前位置:网站首页>resulttype和resultmap的区别和应用场景
resulttype和resultmap的区别和应用场景
2022-07-06 03:00:00 【thoughtCodes】
项目场景:
提示:这里简述项目相关背景:
很开心,又用比较方法解决了这个问题,还是原来解决问题的方法:
1.查2比3累计
问题描述
提示:这里描述项目中遇到的问题:
一、看到这个问题,你可能以为是实体类未在mybatis-config.xml中配置别名(alias)导致的,如下图所示:
进过对比之后,我发现自己的resultMap写成了resultType
原因分析:
提示:这里填写问题的分析:
MyBatis中在查询进行select映射的时候,返回类型可以用resultType,也可以用resultMap,resultType是直接表示返回类型的,而resultMap则是对外部ResultMap的引用,但是resultType跟resultMap不能同时存在。
在MyBatis进行查询映射时,其实查询出来的每一个属性都是放在一个对应的Map里面的,其中键是属性名,值则是其对应的值。
①当提供的返回类型属性是resultType时,MyBatis会将Map里面的键值对取出赋给resultType所指定的对象对应的属性。所以其实MyBatis的每一个查询映射的返回类型都是ResultMap,只是当提供的返回类型属性是resultType的时候,MyBatis对自动的给把对应的值赋给resultType所指定对象的属性。
而且这里是大写对应的map,小写的名字对应的map数值
②当提供的返回类型是resultMap时,因为Map不能很好表示领域模型,就需要自己再进一步的把它转化为对应的对象,这常常在复杂查询中很有作用。
解决方案:
提示:这里填写该问题的具体解决方案:
我填写resulttype 是没问题,赋值出了问题,但是resultMap 会映射的应用的。over. 2个问题已经解决了。
边栏推荐
- Universal crud interface
- codeforces每日5题(均1700)-第六天
- 会员积分营销系统操作的时候怎样提升消费者的积极性?
- [Yu Yue education] basic reference materials of digital electronic technology of Xi'an University of Technology
- Redis skip table
- Gifcam v7.0 minimalist GIF animation recording tool Chinese single file version
- Pure QT version of Chinese chess: realize two-man, man-machine and network games
- Microservice registration and discovery
- Trends in DDoS Attacks
- Deeply analyze the chain 2+1 mode, and subvert the traditional thinking of selling goods?
猜你喜欢
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23](/img/72/a80ee7ee7b967b0afa6018070d03c9.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23

XSS challenges绕过防护策略进行 XSS 注入

主数据管理理论与实践

Qt发布exe软件及修改exe应用程序图标

RobotFramework入门(三)WebUI自动化之百度搜索

How to accurately identify master data?

全国大学生信息安全赛创新实践赛初赛---misc(永恒的夜)

Introduction to robotframework (I) brief introduction and use

微软语音合成助手 v1.3 文本转语音工具,真实语音AI生成器

C # create self host webservice
随机推荐
1. Dynamic parameters of function: *args, **kwargs
Master data management theory and Practice
My C language learning record (blue bridge) -- on the pointer
PMP每日一练 | 考试不迷路-7.5
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20
How does yyds dry inventory deal with repeated messages in the consumption process?
07 单件(Singleton)模式
【Kubernetes 系列】一文學會Kubernetes Service安全的暴露應用
What is the investment value of iFLYTEK, which does not make money?
这些不太会
会员积分营销系统操作的时候怎样提升消费者的积极性?
Elimination games
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 14
Single instance mode of encapsulating PDO with PHP in spare time
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12
Introduction to robotframework (I) brief introduction and use
Installation and use tutorial of cobaltstrike-4.4-k8 modified version
C语言sizeof和strlen的区别
Maturity of master data management (MDM)
原型图设计