当前位置:网站首页>Differences and application scenarios between resulttype and resultmap
Differences and application scenarios between resulttype and resultmap
2022-07-06 03:02:00 【thoughtCodes】
Project scenario :
Tips : Here is a brief introduction to the background of the project :
Very happy , This problem is solved by comparison , Or the original way to solve the problem :
1. check 2 Than 3 Cumulative
Problem description
Tips : The problems encountered in the project are described here :
One 、 See this problem , You may think that the entity class is not in mybatis-config.xml Configuring aliases in (alias) As a result of , As shown in the figure below :
After comparison , I found myself resultMap It has been written. resultType
Cause analysis :
Tips : Fill in the analysis of the problem here :
MyBatis In query select When mapping , Return type can be used resultType, It can also be used. resultMap,resultType Is a direct representation of the return type , and resultMap To the outside ResultMap References to , however resultType Follow resultMap Can't exist at the same time .
stay MyBatis Query mapping , In fact, every attribute found is put in a corresponding Map Inside , Where key is property name , Value is its corresponding value .
① When the return type property provided is resultType when ,MyBatis Will Map The key value pairs in it are assigned to resultType Property corresponding to the specified object . So actually MyBatis The return type of each query mapping of is ResultMap, Only when the return type property provided is resultType When ,MyBatis To assign a corresponding value to resultType Properties of the specified object .
And here is the capital corresponding map, Lowercase names correspond to map The number
② When the return type provided is resultMap when , because Map Can't represent domain model well , We need to further transform it into corresponding objects , This is often useful in complex queries .
Solution :
Tips : Fill in the specific solution to the problem here :
I fill in resulttype No problem. , There is something wrong with the assignment , however resultMap Applications that will be mapped .over. 2 Problems have been solved .
边栏推荐
- tcpdump: no suitable device found
- 2.12 simulation
- js 正则过滤和增加富文本中图片前缀
- Descriptor implements ORM model
- tcpdump: no suitable device found
- Technology sharing | what if Undo is too big
- Introduction to robotframework (II) app startup of appui automation
- PMP practice once a day | don't get lost in the exam -7.5
- Differences and usage scenarios between TCP and UDP
- 继承day01
猜你喜欢
Installation and use tutorial of cobaltstrike-4.4-k8 modified version
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
主数据管理理论与实践
Referenceerror: primordials is not defined error resolution
淘宝焦点图布局实战
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23
一个复制也能玩出花来
2022工作中遇到的问题四
主数据管理(MDM)的成熟度
2345 file shredding, powerful file deletion tool, unbound pure extract version
随机推荐
QT release exe software and modify exe application icon
Introduction to robotframework (III) Baidu search of webui automation
Large scale DDoS attacks take Myanmar offline
Single instance mode of encapsulating PDO with PHP in spare time
RobotFramework入门(三)WebUI自动化之百度搜索
华为、H3C、思科命令对比,思维导图形式从基础、交换、路由三大方向介绍【转自微信公众号网络技术联盟站】
My C language learning records (blue bridge) -- files and file input and output
Is there a completely independent localization database technology
Jenkins basic knowledge ----- detailed explanation of 03pipeline code
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 18
Codeworks 5 questions per day (1700 average) - day 6
Communication between microservices
Solve 9 with C language × 9 Sudoku (personal test available) (thinking analysis)
Maturity of master data management (MDM)
Pure QT version of Chinese chess: realize two-man, man-machine and network games
Network Security Learning - Web vulnerabilities (Part 1)
#PAT#day10
Who is the winner of PTA
Yyds dry inventory comparison of several database storage engines
Selenium share