Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-01 05:59:23 10月02日 Update

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.

Tags: Type parameter condition dynamic content empty character data article knowledge article value most character string entity that is attribute case more sometimes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Linux Shulou Tech Info MySQL Apple