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

  • 相关阅读:
    mysql设置用户密码规则
    jsonp格式前端发送和后台接受写法
    MySql数据库中正则表达式
    linux中服务(service)管理
    第50课 C++对象模型分析(上)
    第49课 多态的概念和意义
    第42课
    第41课
    深入理解MyBatis中的一级缓存与二级缓存
    hibernate一级缓存和二级缓存的区别
  • 原文地址:https://www.cnblogs.com/lzy1212/p/13294171.html
Copyright © 2011-2022 走看看