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

  • 相关阅读:
    无线路由器的工作模式
    php 利用root 权限执行shell脚本
    shell 终端常用插件
    linux space/mark设置
    推送唯一标识符
    微信支付跨平台软件架构
    celery 动态配置定时任务
    两个报文是如何进行 TCP 分组传输
    接口 Interfaces
    How does Circus stack compare to a classical stack?
  • 原文地址:https://www.cnblogs.com/lzy1212/p/13294171.html
Copyright © 2011-2022 走看看