当前位置:网站首页>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
- DDoS "fire drill" service urges companies to be prepared
- jsscript
- Fault analysis | analysis of an example of MySQL running out of host memory
- tcpdump: no suitable device found
- CSP date calculation
- What is the investment value of iFLYTEK, which does not make money?
- 1. Dynamic parameters of function: *args, **kwargs
- 2345文件粉碎,文件强力删除工具无捆绑纯净提取版
- Solve 9 with C language × 9 Sudoku (personal test available) (thinking analysis)
猜你喜欢
纯Qt版中国象棋:实现双人对战、人机对战及网络对战
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 22
ERA5再分析资料下载攻略
GifCam v7.0 极简GIF动画录制工具中文单文件版
【若依(ruoyi)】设置主题样式
My C language learning record (blue bridge) -- under the pointer
QT release exe software and modify exe application icon
Introduction to robotframework (II) app startup of appui automation
2345文件粉碎,文件强力删除工具无捆绑纯净提取版
My C language learning record (blue bridge) -- on the pointer
随机推荐
#PAT#day10
Microservice registration and discovery
Game theory matlab
Classic interview question [gem pirate]
Pat 1046 shortest distance (20 points) simulation
Daily question brushing plan-2-13 fingertip life
【 kubernets series】 a Literature Study on the Safe exposure Applications of kubernets Service
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 19
Referenceerror: primordials is not defined error resolution
JS events (add, delete) and delegates
Force buckle 146 LRU cache
Linear regression and logistic regression
Software design principles
多态day02
Modeling specifications: naming conventions
Patch NTP server at the beginning of DDoS counterattack
Reverse repackaging of wechat applet
纯Qt版中国象棋:实现双人对战、人机对战及网络对战
解决:AttributeError: ‘str‘ object has no attribute ‘decode‘
Pat 1084 broken keyboard (20 points) string find