一般在mybatis中插入或者修改时,会将字段做非null和非空判断,如下所示:
<if test="operatype_enum != null and operatype_enum != ''">
operatype_enum =#{operatype_enum},
</if>
这样写,当operatype_enum=0时,mybatis将不会插入改字段,因为mybatis框架会将operatype_enum识别为空字符串,
所以如果想要将0值插入进去,有一下几种方法解决:
1.直接改框架源代码
2.更改if判断条件如下所示
<if test="operatype_enum != null">
operatype_enum =#{operatype_enum},
</if>
或
<if test="operatype_enum != null and operatype_enum != '' or operatype_enum == 0">
operatype_enum =#{operatype_enum},
</if>