最初代码:
<update id="updateCollectionStatus">
update test_collection <choose>
<when test="delFlag == '1'.toString()">
set del_flag='0'
</when>
<otherwise>
set del_flag='1'
</otherwise>
</choose>
where test_id=#{testId}and user_id=#{userId}
</update>
结果:一直执行otherwise标签中的方法:
解决方法:
<update id="updateCollectionStatus">
update test_collection <choose>
<when test="delFlag == '1'.toString()">
set del_flag='0'
</when>
<otherwise>
set del_flag='1'
</otherwise>
</choose>
where test_id=#{testId}and user_id=#{userId}
</update>
参考内容:
https://code.google.com/p/mybatis/issues/detail?id=262