Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What conditions should dynamic sql pay attention to when mybatis encounters parameters of type Integer?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

The knowledge of this article "mybatis encounters Integer type parameters when dynamic sql needs to pay attention to what conditions" is not understood by most people, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "mybatis encounters Integer type parameters when dynamic sql needs to pay attention to what conditions" article.

Mybatis Integer type parameter dynamic sql attention conditions such as dynamic sql and T.status=# {work_status,jdbcType=INTEGER} concatenated below

When work_status is 0, Mybatis parses 0 to the empty string'', so if determines it to be false. If you want to correctly add the query condition after and, you should change it to

Pit of and T.status=# {work_status,jdbcType=INTEGER} mybatis-- parsing of Integer type parameters sometimes when we use entity classes to pass parameters

Some properties are set to Integer types, such as status, sort, etc. Here, when using the Integer type parameter as a condition, you should pay attention to one thing: for example

AND activity_sort = # {bean.activitySort,jdbcType=VARCHAR}

Under normal circumstances, if activitySort is of type String, it is normal to judge whether it is an empty string, but if activitySort is a parameter of type Integer, you should note that you cannot judge an empty string of activitySort here because of what?

Because when mybatis parses Integer type data

If the data value is 0, 0 will be parsed to an empty string, so the parameters you pass in will become invalid, so the normal use of Integer type parameters should be as follows:

AND activity_sort = # {bean.activitySort,jdbcType=VARCHAR} above is the content of this article on "what conditions should dynamic sql pay attention to when mybatis encounters parameters of Integer type". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about related knowledge, please 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report