Cunming Bian
Cunming Bian

Reputation: 11

Mybatis query parameters are 0, the data is abnormal. Why?

I was doing graduation design process, found that when the query parameters are 0, mybatis query results are not correct. Mapper configuration as shown enter image description here

status parameter is Integer, MySQL database field type is int, when the status is 0, the result is wrong, 1,2,3,4 are correct. Please be familiar with mybatis big gods under the instructions.

Upvotes: 1

Views: 389

Answers (1)

Michael Peacock
Michael Peacock

Reputation: 2104

When your status parameter = 0, your SQL will be:

SELECT rr.*, cc.* from (
SELECT * FROM recruitment r
WHERE 1=1 
AND r.rec_status = 0
) ...

You're only checking all of your parameters against null and empty strings. If you pass 0 for any of these, these tests will pass and the SQL will be changed to include those zeroes.

Upvotes: 1

Related Questions