【问题标题】:Mybatis query parameters are 0, the data is abnormal. Why?Mybatis查询参数为0,数据异常。为什么?
【发布时间】:2017-09-17 08:33:26
【问题描述】:

我在做毕业设计过程,发现查询参数为0时,mybatis查询结果不正确。 Mapper配置如图enter image description here

status参数为Integer,MySQL数据库字段类型为int,status为0时结果错误,1,2,3,4正确。 请在说明下熟悉mybatis大神。

【问题讨论】:

    标签: java mysql spring mybatis


    【解决方案1】:

    当您的状态参数 = 0 时,您的 SQL 将是:

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

    您只是针对空字符串和空字符串检查所有参数。如果您为其中任何一个通过 0,则这些测试将通过,并且 SQL 将更改为包含这些零。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-02
      • 2015-03-07
      • 2019-06-09
      • 1970-01-01
      • 2022-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多