关于mybatis 特殊案例

一、boolean类型判定:

jdbcType选择BIT,选择BOOLEAN有可能无法正常识别;

一种可行方案:

<choose>
<when test="completed != null and 'true'.toString() == completed.toString()">
<![CDATA[
AND sf.REMAIN < #{completed,jdbcType=BIT}
]]>
</when>
<when test="completed != null and 'false'.toString() == completed.toString()">
<![CDATA[
AND sf.REMAIN > #{completed,jdbcType=BIT}
]]>
</when>
</choose>

另外一种方案:

<if test="completed != null and 'true'.toString() == completed.toString()">
  <![CDATA[
    AND sf.REMAIN < #{completed,jdbcType=BIT}
  ]]>
</if>
<if test="completed != null and 'false'.toString() == completed.toString()">
  <![CDATA[
    AND sf.REMAIN > #{completed,jdbcType=BIT}
  ]]>
</if>

 

posted on 2022-08-11 10:51  arduino  阅读(22)  评论(0编辑  收藏  举报

导航