当前位置:网站首页>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 .
边栏推荐
- Introduction to robotframework (III) Baidu search of webui automation
- Is there a completely independent localization database technology
- RobotFramework入门(二)appUI自动化之app启动
- Network Security Learning - Web vulnerabilities (Part 1)
- Atcoder beginer contest 233 (a~d) solution
- [network security interview question] - how to penetrate the test file directory through
- MySQL advanced notes
- Detailed use of dbutils # yyds dry goods inventory #
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24
- 深度解析链动2+1模式,颠覆传统卖货思维?
猜你喜欢
Game theory matlab
Which ecology is better, such as Mi family, graffiti, hilink, zhiting, etc? Analysis of five mainstream smart brands
微软语音合成助手 v1.3 文本转语音工具,真实语音AI生成器
【指针训练——八道题】
What is the investment value of iFLYTEK, which does not make money?
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21
一个复制也能玩出花来
Universal crud interface
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 18
微服务间通信
随机推荐
Technology sharing | what if Undo is too big
Universal crud interface
主数据管理(MDM)的成熟度
RobotFramework入门(一)简要介绍及使用
My C language learning record (blue bridge) -- under the pointer
Spherical lens and cylindrical lens
MySQL advanced notes
Pure QT version of Chinese chess: realize two-man, man-machine and network games
CSP numeric sort
PMP每日一练 | 考试不迷路-7.5
Detailed use of dbutils # yyds dry goods inventory #
一个复制也能玩出花来
DDoS attacks - are we really at war?
解决:AttributeError: ‘str‘ object has no attribute ‘decode‘
What are the principles of software design (OCP)
07 singleton mode
CobaltStrike-4.4-K8修改版安装使用教程
【若依(ruoyi)】设置主题样式
1003 emergency (25 points), "DIJ deformation"
Data and Introspection__ dict__ Attributes and__ slots__ attribute