zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    ElasticSearch集群设置
    NEST与JSON语法对照 一 match与multi_match
    某墙尼妹,用个Response.Filter来解决StackExchange.Exceptional中google cdn的问题
    高频
    Linux 后台执行命令
    Mysql 常用函数汇总
    Golang 昨天、今天和明天
    Golang——Cron 定时任务
    Golang 资料整理
    Golang: for range
  • 原文地址:https://www.cnblogs.com/lzy1212/p/13294171.html
Copyright © 2011-2022 走看看