In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the example analysis of foreach nested if tags in mybatis. I hope you will get something after reading this article. Let's discuss it together.
Mybatis foreach nested if tags
Code implementation:
Mapper.java file
List getYsxmcodeByYszbh (@ Param ("qyName") List qyName, @ Param ("yszh") String yszh)
XXX.xml file
Union select ysxmcode from ${qy} _ yxsxk.tpc_ysxkz where yszbh=# {yszh,jdbcType=VARCHAR}
To judge whether it is the first loop, do not add union splicing, otherwise add
The difference between xml files $and #
${} will be directly replaced by variables when precompiled, but there is a problem of being injected, the table name must be ${}, because # {} will be resolved to? Placeholder, but when replaced by a variable, single quotation marks are added to indicate that single quotation marks are not allowed (but backquotation marks ``are OK)
The difference between union and union all
1.union all is a direct connection, taking all the values, the record may be duplicated; union is the only value, the record is not duplicated. So union will filter out duplicate records after table linking, and union all will not remove duplicate records.
2.union will sort by the order of the fields; union all will simply merge the two results and return. Union all is much faster than union in terms of efficiency, so use union all if you can confirm that the two merged result sets do not contain duplicate data and do not need to be sorted.
The nesting of mybatis if and foreach (an indefinite number of query conditions with the same column) has such a requirement
Set different number of query conditions according to the number of entries (set an indefinite number of query conditions on a column), then you need a root.
According to the foreach loop, the query conditions are spliced on a column.
The template is shown below.
After reading this article, I believe you have some understanding of "sample Analysis of foreach nested if tags in mybatis". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
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.