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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM