关于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>