mybatis_4 xml常用判断条件

javaType="java.util.Map"
javaType="double" jdbcType="NUMERIC"
javaType="string" jdbcType="VARCHAR"
javaType="java.sql.Date" jdbcType="DATE"
javaType="int" jdbcType="INTEGER"
javaType="double" jdbcType="DOUBLE"
javaType="long" jdbcType="INTEGER"
javaType="string" jdbcType="CHAR"
javaType="[B" jdbcType="BLOB"
javaType="string" jdbcType="CLOB"
javaType="float" jdbcType="FLOAT"
javaType="java.sql.Timestamp" jdbcType="TIMESTAMP"

//1.mybatis
//长度
<if test="orgCode.length() == 1"></if>
//相等
<if test='taskDefKey.equals("AAA")'></if>
// 字符相等 即最外边用双引号,里边用单引号,此写法会报java.lang.NumberFormatException
<if test="stringParam != null and stringParam != 'a'"></if>
//判断存在
<if test="stringParam.indexOf('aa') != -1"></if>
//判断Integer是否大于0 gt大于,lt小于
<if test="idParam !=null and idParam gt 0"></if>
//like
<if test="title != null">
     AND  title LIKE CONCAT(CONCAT('%',#{title}),'%')
</if>
//时间区间
<if test="startTime!=null  and  startTime!='' ">
    and DATE_FORMAT(p.PRJ_HTWC_DATE, '%Y-%m-%d') <![CDATA[ >= ]]>  DATE_FORMAT(#{startTime}, '%Y-%m-%d')
</if>
<if test="endTime!=null  and  endTime!=''">
    and DATE_FORMAT(p.PRJ_HTWC_DATE, '%Y-%m-%d') <![CDATA[ <= ]]>   DATE_FORMAT(#{endTime}, '%Y-%m-%d')
</if>
//多条件判断
<choose>
    <when test="sameEmailList != null and sameEmailList.size > 0 ">
    </when>
    <when test="">
    </when>
    <otherwise>
    </otherwise>
</choose>

猜你喜欢

转载自blog.csdn.net/qq_41859067/article/details/84451172