In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article Xiaobian for you to introduce in detail "mybatis using Integer type query how to solve the problem", detailed content, clear steps, details handled properly, I hope that this "mybatis using Integer type query how to solve the problem" article can help you solve doubts, the following follow the editor's ideas slowly in-depth, together to learn new knowledge.
Problems with using Integer type queries
Mapper.xml:
Select count (m.id) from hr_push_msg_model as m m.text like'% ${page.keyword}% 'and m.text like' ${page.entity.text}%' And m.title like'% {page.entity.title}% 'and m.state = # {page.entity.state} and m.type = # {page.entity.type}
For example:
And m.state = # {page.entity.state} when the state value is 0
Mybatis defaults to the empty string "", so if a similar scenario like state is worth it, don't add xxxxxexamples = "" to the query. Or or xxx==0.
Code example:
1 、
And m.state = # {page.entity.state}
2 、
And m.state = # {page.entity.state} mybatis to determine the output of bug scenarios encountered by Integer
All users with status 0 need to be found out.
That's what I wrote.
1.mapper:
BaseUser selectUserByStatus (@ parm ("status") Integer status)
There's a zero in here.
2.sql:
SELECT * FROM base_user WHERE status=0
3.xml fragment
Status = # {status}
4. As a result, the sql actually executed
SELECT * FROM base_user
A brief summary:
Test= "status! = null and status! =''" this is used to judge String! In other words, the same situation can happen to numeric types such as Double,BigDecimal.
1. If it is of type Integer, if the value of the variable is 0, that is, num = 0, mybatis will think that the value of num is an empty string when performing num! =''"; skip the judgment directly
So if it is Integer type, you only need to judge! = null.
two。 If the String type needs to be judged to be not equal to 0, you need to write name! = '0'.toString (), otherwise an error will be reported.
Read here, this "mybatis using Integer type query how to solve the problem" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more about the article, welcome to follow 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.