数据库-mybatis

  • Mybatis if test中字符串比较
<if test=" name=='你好' ">
<if>

这样会有问题,换成

<if test=' name=="你好" '>
<if>
  • 判断集合是否为空及循环
<if test="appStatusList !=null and appStatusList.size()>0">
    and ap.status in
    <foreach collection="appStatusList" index="index" item="item" open="(" separator="," close=")">
        #{item}
    </foreach>
</if>
  • choose-when语句
<choose>
    <when test='importFlag == "IMPORTED_SUCCESS"'>
        AND ap.status ='IMPORTED_SUCCESS'
    </when>
    <when test='importFlag == "IMPORTED_ERROR"'>
        AND ap.status ='IMPORTED_ERROR'
    </when>
    <when test='importFlag == "UNIMPORTED"'>
        AND ap.status = 'CHECKED'
    </when>
</choose>

猜你喜欢

转载自blog.csdn.net/yulong1026/article/details/81780925