mybatis注意事项

---------------------以数组作为查询条件,判断数组大小

<if test="dateList != null and dateList.size() > 0">

        and DATE_FORMAT(tfp.update_time, '%Y-%m-%d') in

        <foreach item="date" index="index" collection="dateList" open="(" separator="," close=")">  

 #{date}  

</foreach> 

</if> 

 

------------------------mybatis字符串比较方法

<if test='deviceStatus != null and deviceStatus != "" and deviceStatus == "0" '>

and (vdm.`status` is null or vdm.`status` = '')

</if>

 

注意单引号和双引号的用法

<if test='deviceStatus != null and deviceStatus != "" and deviceStatus == "0" '>

and (vdm.`status` is null or vdm.`status` = '')

</if>

 

注意单引号和双引号的用法

 

-------------------------------参数数组判断空

<if test="deviceIds != null and deviceIds.size() > 0">

and t.DEVICE_ID in

<foreach item="deviceId" index="index" collection="deviceIds"

open="(" separator="," close=")">

#{deviceId}

</foreach>

</if>

 

mybatis存储过程类型定义如下:

 

http://blog.csdn.net/woshixuye/article/details/12953803

 

你可能感兴趣的:(mybatis)