In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article "MyBatis how to achieve multi-table joint query resultType return value" most people do not understand the knowledge points of the article, so Xiaobian summarized the following content for everyone, detailed content, clear steps, with a certain reference value, I hope you can read this article to gain something, let's take a look at this article "MyBatis how to achieve multi-table joint query resultType return value" article bar.
Return value of multi-table union query resultType General data returned by parameter type select id from t_car_car SELECT deptname FROM t_car_run where deptid = #{deptid} GROUP BY deptname Query according to a field
The returned type is entity class, because the query result data is the data of fields in entity class.
select number from t_car_car where id = #{carid} Query result is multiple records, stored in list Return
The returned type is entity class, because the query result data is the data of fields in entity class.
select * from t_car_car multi-table union query
t_car_car
t_car_driver
t_car_cardriver
The two fields stored in t_car_cardriver are the primary key id of t_car_car and t_car_driver respectively.
solutions
The return type of resultType is java.util.Map.
All the data stored in the List is returned.
select driverid from t_car_cardriver where carid = #{id}
2. Create a new entity class
It stores the field names required in the query results.
// TCarCarDriverprivate Long carid;private Long driverid;
The return type is the entity class
select driver id from t_car_cardriver where carid = #{id} multi-table query, return nested list of results
Multi-level nesting of collections returns results using resultMap,collection using resultMap again
select tc.id as tid, tci.id as iid, tciw.id as wid, tmq.id as qid, access_key, secret_key, outer_chain_name, outer_chain_document, intention_name, question, word_slot, word_slot_miss_question, entity_type_ids from t_chain tc left join t_chain_intention tci on tc.id = tci.chain_id left join t_chain_intention_word tciw on tci.id = tciw.intention_id left join t_multi_question tmq on tci.id = tmq.parent_id where tc.id = #{id} and tc.deleted = 0 above is about the content of this article "how MyBatis realizes the return value of multi-table joint query resultType". I believe everyone has a certain understanding. I hope the content shared by Xiaobian will be helpful to everyone. If you want to know more relevant knowledge content, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.