Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Mybatis to receive Integer parameters

Shulou Source: shulou.com Published: 2022-06-01 05:57:39 09月26日 Update

Editor to share with you how to use Mybatis to receive Integer parameters, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Mybatis receives Integer parameters

Recently, when I was working on a project, there was a problem when using tags to determine paging parameters in mybatis.

LIMIT # {startRow}, # {selectRow}

This code is used to set paging parameters in SQL, and the received parameters are of type Integer.

We all know that to query the first page, startRow needs to be assigned a value of 0, but this code doesn't work. Normally, 0 is neither null nor an empty string

However, when consulting the data, we know that when mybatis receives the Integer parameter, if the parameter value is 0, it will be parsed to an empty string''.

Solution LIMIT # {startRow}, # {selectRow}

1. Only judge that the Integer parameter is not null, not an empty string.

two。 It can be judged that the parameter is not equal to 0 (not applicable in my case)

Mybatis uses the Integer type when the descendant mybatis forms a sql statement

When a value of type int passed in is 0, it is considered an empty string, so as long as you judge it this way

It will be fine:

AND info.pay_status = # {payStatus}

When the value of payStatus is 0, add another payStatus==0 to enter the if.

The above is all the content of the article "how to use Mybatis to receive Integer parameters". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Parameters null characters types articles code content not much not in use pass on functions examples methods most time more tags knowledge industry statements Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Apple Redmi MySQL Docker