使用HASP地图中的MyBatis基于ONGL表达式(例如:如果选择)

问题描述:

我有哪里我打电话的MyBatis查询使用哈希映射使用HASP地图中的MyBatis基于ONGL表达式(例如:如果选择)

Java代码的一个场景:

public object testMethod(String number. string name){ 

Map<String , String> param = new HashMap<String,String>(); 

param.put("number",number); 
param.put("name",name); 

return getSqlSession().selectOne("testDao.fetchData",param); 

testDao.xml:

<select id = "fetchData" parameterType = "java.util.HashMap" resultType = "object"> 

SELECT name,address,phone from customer where customer_no = #{number} 

<if test= "name != null and name != 't'"> 
and status = 'V' 
</if> 
fetch first row only 
</select> 

上面的查询正在执行,它没有引发错误,但参数为空。这是什么原因?

我已在Logger和Parameters中验证过null。

+0

什么数据类型是customer_no字段? –

我不确定为什么条件语句不能在上面的代码中工作。当我已经改变了代码看起来工作正常

我已经改变

<if test= "name != null and name != 't'"> 
and status = 'V' 
</if> 

<if test= '"t".equals(name)'> 
    and status = 'V' 
</if> 

这可能会发生,因为我们在单引号给变量t(这意味着字符)而不是双引号(字符串)