Java HashMap中的绑定空值

Java HashMap中的绑定空值,java,mysql,Java,Mysql,我正在制作一个参数输入表单来查询审计表。不需要输入 下面的SQL查询是我希望Java解析的查询,它可以完美地工作。它根据输入返回我想要的行 SELECT * FROM _audit WHERE DATEDIFF(NOW(), `_audit_timestamp`) < 30 AND (('smith' <> '' AND _action__user = 'smith') OR (_action__user = _action__user AND

我正在制作一个参数输入表单来查询审计表。不需要输入

下面的SQL查询是我希望Java解析的查询,它可以完美地工作。它根据输入返回我想要的行

SELECT *
FROM _audit
WHERE DATEDIFF(NOW(), `_audit_timestamp`) < 30
      AND (('smith' <> '' AND _action__user = 'smith')
           OR (_action__user = _action__user AND 'smith' IS NULL))
      AND ((NULL IS NOT NULL AND _action_searchkey IS NULL)
           OR (_action_searchkey = _action_searchkey OR _action_searchkey IS NULL))
      AND ((NULL IS NOT NULL AND _action_customer IS NULL)
           OR (_action_customer = _action_customer AND _action_customer IS NULL))
ORDER BY _audit_timestamp DESC
选择*
来自审计部
其中DATEDIFF(NOW(),`u audit\u timestamp`)小于30
和(('smith''和_action__用户='smith')
或(\u action\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
和((NULL不为NULL,并且_action_searchkey为NULL)
或(_action_searchkey=_action_searchkey或_action_searchkey为空))
和((NULL不为NULL,并且_action_customer为NULL)
或(_action_customer=_action_customer和_action_customer为空))
订单依据\u审核\u时间戳说明
然而,当我试图让它在Java中工作时,它根本不返回任何行。我认为这与地图上的价值观有关。在调试器中查看它们时,会显示“”而不是NULL

    String sqlText = "SELECT * "
            + "       FROM _audit "
            + "       WHERE DATEDIFF(NOW(), `_audit_timestamp`) < :days "
            + "       AND ((:Name IS NOT NULL AND _action__user = :Name) "
            + "           OR (_action__user = _action__user AND :Name IS NULL)) "
            + "       AND ((:SearchKey IS NOT NULL AND _action_searchkey = :SearchKey) "
            + "             OR (_action_searchkey = _action_searchkey AND :SearchKey IS NULL)) "
            + "       AND ((:Customer IS NOT NULL AND _action_customer = :Customer) "
            + "           OR (_action_customer = _action_customer AND :Customer IS NULL)) "
            + "       ORDER BY _audit_timestamp DESC";

    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("days", aqForm.getDays().toString());
    parameters.put("Name", aqForm.getName());
    parameters.put("SearchKey", aqForm.getSearchKey());
    parameters.put("Customer", aqForm.getCustomer());
String sqlText=“选择*
+“来自审计”
+“其中DATEDIFF(现在(),`u audit\u timestamp`)<:天”
+“和(:Name不为NULL且_action_uuser=:Name)”
+“或(_action_uuuuuser=_action_uuuuser AND:Name为NULL))”
+“和((:SearchKey不为NULL且_action_SearchKey=:SearchKey)”
+“或(_action_searchkey=_action_searchkey AND:searchkey为NULL))”
+“和((:Customer不为NULL且_action_Customer=:Customer)”
+“或(_action_customer=_action_customer AND:customer为NULL))”
+“订单审核时间戳描述”;
映射参数=新的HashMap();
parameters.put(“days”,aqForm.getDays().toString());
parameters.put(“Name”,aqForm.getName());
parameters.put(“SearchKey”,aqForm.getSearchKey());
parameters.put(“Customer”,aqForm.getCustomer());

我在这里选错树了吗?

在查询中用替换并尝试。

建议:不要在参数名称中交替使用大写和小写字符。一致性是关键。