当前位置:网站首页>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 .
边栏推荐
- 纯Qt版中国象棋:实现双人对战、人机对战及网络对战
- 不赚钱的科大讯飞,投资价值该怎么看?
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23
- 07 singleton mode
- Daily question brushing plan-2-13 fingertip life
- Large scale DDoS attacks take Myanmar offline
- Apt installation ZABBIX
- Solution: attributeerror: 'STR' object has no attribute 'decode‘
- A copy can also produce flowers
- 多态day02
猜你喜欢
C # create self host webservice
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 14
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12
Codeforces 5 questions par jour (1700 chacune) - jour 6
一个复制也能玩出花来
Microservice registration and discovery
ERA5再分析资料下载攻略
【Kubernetes 系列】一文學會Kubernetes Service安全的暴露應用
Yyds dry inventory comparison of several database storage engines
Software design principles
随机推荐
Single instance mode of encapsulating PDO with PHP in spare time
Linear programming matlab
Detailed use of dbutils # yyds dry goods inventory #
Briefly describe the implementation principle of redis cluster
[unity3d] GUI control
Rust language -- iterators and closures
2345 file shredding, powerful file deletion tool, unbound pure extract version
codeforces每日5题(均1700)-第六天
【Kubernetes 系列】一文学会Kubernetes Service安全的暴露应用
2.13 simulation summary
The difference between sizeof and strlen in C language
PMP每日一练 | 考试不迷路-7.5
【 kubernets series】 a Literature Study on the Safe exposure Applications of kubernets Service
Introduction to robotframework (I) brief introduction and use
DDoS attacks - are we really at war?
这些不太会
[pointer training - eight questions]
会员积分营销系统操作的时候怎样提升消费者的积极性?
微服务间通信
Classic interview question [gem pirate]