In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
The purpose of this article is to share with you what to do if the parameter value of Integer type is 0 in Mybatis. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The problems encountered today:
When querying version information, because version is an Integer type, when the foreground selects version 0, it queries all version information.
Sql fragment:
AND a.version = # {version}
Reason:
MyBatis defaults to "" (empty string) when the Integer type data value equals 0 for its own reasons.
Solution:
1. In some cases, you can intercept at Controller and prompt the receptionist, for example, "you must enter a valid number" to prevent him from passing it back.
two。 Delete the judgment condition version! =''and do not let it judge.
Such as:
AND a.version = # {version}
The downside: when a guy really passes an empty string in this way, it's impossible to tell.
3. Add separately the special case when version is 0
Such as:
AND a.version = # {version}
Of course, if you want to query all (similar to the above example) when the default input is 0, or you want to convert to an empty string later.
You don't have to change it, but you can also skillfully use "bug".
Thank you for reading! This is the end of the article on "what to do if you get empty when the parameter value of Integer type in Mybatis is 0". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.