当前位置:网站首页>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个问题已经解决了。
边栏推荐
- How does yyds dry inventory deal with repeated messages in the consumption process?
- js 正则过滤和增加富文本中图片前缀
- Prototype design
- 会员积分营销系统操作的时候怎样提升消费者的积极性?
- What is the investment value of iFLYTEK, which does not make money?
- My C language learning records (blue bridge) -- files and file input and output
- Linear programming matlab
- Master data management theory and Practice
- 建模规范:命名规范
- OCR文字识别方法综述
猜你喜欢

Codeforces 5 questions par jour (1700 chacune) - jour 6

A copy can also produce flowers
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 17](/img/85/2635afeb2edeb0f308045edd1f3431.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 17

My C language learning record (blue bridge) -- under the pointer

JS regular filtering and adding image prefixes in rich text

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

Force buckle 146 LRU cache

如何精准识别主数据?
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9](/img/ed/0edff23fbd3880bc6c9dabd31755ac.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9

Who is the winner of PTA
随机推荐
Fault analysis | analysis of an example of MySQL running out of host memory
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 20
OCR文字识别方法综述
Prototype design
The difference between sizeof and strlen in C language
手写数据库客户端
DDoS "fire drill" service urges companies to be prepared
GifCam v7.0 极简GIF动画录制工具中文单文件版
Huawei, H3C, Cisco command comparison, mind map form from the basic, switching, routing three directions [transferred from wechat official account network technology alliance station]
"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.3 linear algebra_ Learning thinking and exercise answers
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 13
Custom attribute access__ getattribute__/ Settings__ setattr__/ Delete__ delattr__ method
Qt发布exe软件及修改exe应用程序图标
Misc (eternal night), the preliminary competition of the innovation practice competition of the National College Students' information security competition
【若依(ruoyi)】设置主题样式
不赚钱的科大讯飞,投资价值该怎么看?
Microsoft speech synthesis assistant v1.3 text to speech tool, real speech AI generator
Linear programming matlab
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21
Day 50 - install vsftpd on ceontos6.8