mybatis动态SQl中int类型字段为0 SQl语句不拼接

mybatis内容

<update id="updateExpressById" parameterType="java.util.Map">
        update WEB_EXPRESS
        <trim prefix="set" suffixOverrides=",">
            <if test="eNum !=null and eNum!=''">
                ENUM = #{eNum},
            </if>

            <if test="company !=null and company!=''">
                COMPANY = #{company},
            </if>

            <if test="uPhone !=null and uPhone!=''">
                UPHONE = #{uPhone},
            </if>

            <if test="username != null and username!=''">
                USERNAME = #{username},
            </if>

            <if test="inTime != null and inTime!=''">
                INTIME = #{inTime},
            </if>

            <if test="eStatus != null and eStatus!=''">
                ESTATUS = #{eStatus},
            </if>

            <if test="outTime != null and outTime!=''">
                OUTTIME = #{outTime},
            </if>

            <if test="cPhone != null and cPhone!=''">
                CPHONE = #{cPhone},
            </if>

            <if test="code != null and code!=''">
                CODE = #{code},
            </if>
        </trim>
        where ID = #{id}
    </update>

业务代码 将参数加入map集合中

        Map map = new ConcurrentHashMap();
        map.put("eStatus",2);
        map.put("outTime",DateUtil.getTime());
        map.put("cPhone", CookieUtil.getCookie("userId",request));
        map.put("code",0);
        map.put("id",id);    

 

控制台的sql日志

sql语句拼接直接忽略了CODE = #{code}

解决办法 将0作为字符串存入map

map.put("code","0");

ok 问题解决 该数据在mysql客户端中也为0

posted @ 2020-07-13 16:56  火星的巧克力  阅读(1092)  评论(0编辑  收藏  举报
/* 返回顶部代码 */ TOP