【发布时间】:2017-09-17 08:33:26
【问题描述】:
我在做毕业设计过程,发现查询参数为0时,mybatis查询结果不正确。 Mapper配置如图enter image description here
status参数为Integer,MySQL数据库字段类型为int,status为0时结果错误,1,2,3,4正确。 请在说明下熟悉mybatis大神。
【问题讨论】:
我在做毕业设计过程,发现查询参数为0时,mybatis查询结果不正确。 Mapper配置如图enter image description here
status参数为Integer,MySQL数据库字段类型为int,status为0时结果错误,1,2,3,4正确。 请在说明下熟悉mybatis大神。
【问题讨论】:
当您的状态参数 = 0 时,您的 SQL 将是:
SELECT rr.*, cc.* from (
SELECT * FROM recruitment r
WHERE 1=1
AND r.rec_status = 0
) ...
您只是针对空字符串和空字符串检查所有参数。如果您为其中任何一个通过 0,则这些测试将通过,并且 SQL 将更改为包含这些零。
【讨论】: