zoukankan      html  css  js  c++  java
  • mybatis xml中常见配置demo

    新增:

    <insert id="insertSelective" parameterType="map" >
        insert into BS_CHNGROUP_DICT
        <trim prefix="(" suffix=")" suffixOverrides="," >
          <if test="groupName != null" >
            GROUP_NAME,
          </if>
          <if test="hasChild != null" >
            HAS_CHILD,
          </if>
          <if test="queryIndex != null" >
            QUERY_INDEX,
          </if>
          <if test="activeTime != null" >
            ACTIVE_TIME,
          </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides="," >
          <if test="groupName != null" >
            #{groupName,jdbcType=VARCHAR},
          </if>
          <if test="hasChild != null" >
            #{hasChild,jdbcType=CHAR},
          </if>
          <if test="queryIndex != null" >
            #{queryIndex,jdbcType=DECIMAL},
          </if>
          <if test="activeTime != null" >
            #{activeTime,jdbcType=TIMESTAMP},
          </if>
        </trim>
      </insert>

    修改:

      1.

     <update id="updateByPrimaryKeySelective" parameterType="map" >
        update BS_STAFF_STATUS
        <set >
          <if test="status != null" >
            STATUS = #{status,jdbcType=VARCHAR},
          </if>
          <if test="enterTime != null" >
            ENTER_TIME = #{enterTime,jdbcType=TIMESTAMP},
          </if>
          <if test="insertTime != null" >
            INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
          </if>
          <if test="deptId != null" >
            DEPT_ID = #{deptId,jdbcType=VARCHAR},
          </if>
          <if test="phoneNo != null" >
            PHONE_NO = #{phoneNo,jdbcType=VARCHAR},
          </if>
        </set>
        where STAFF_ID = #{staffId,jdbcType=VARCHAR}
      </update>

     查询

      1.

      

    <select id="selectSelective" resultType="map" parameterType="map" >
        select 
        <include refid="Base_Column_List" />
        from BS_QUESTION_TRACE_INFO a
        <trim prefix="WHERE" prefixOverrides="AND |OR ">  
            <if test="questionId != null" >
                and QUESTION_ID = #{questionId,jdbcType=CHAR} 
              </if>
              <if test="preStatus != null">  
                and PRE_STATUS = #{preStatus,jdbcType=CHAR}  
            </if>
            <if test="curStatus != null">  
                and CUR_STATUS = #{curStatus,jdbcType=CHAR}  
            </if>
            <if test="oprType != null">  
                and OPR_TYPE = #{oprType,jdbcType=CHAR}  
            </if>
            <if test="questionOwnerId != null">
                and QUESTION_OWNER_ID = #{questionOwnerId,jdbcType=CHAR}  
            </if>
        </trim> 
      </select>

      

  • 相关阅读:
    开源 Serverless 里程碑:Knative 1.0 来了
    以一致的体验交付和管理云原生多集群应用
    iLogtail使用入门K8S环境日志采集到SLS
    如何在golang代码里面解析容器镜像
    mac vmware 无法复制粘贴
    使用vi编辑时上下左右方向键被转化为A、B、C、D
    left join 和 left outer join 的区别
    设计模式之 适配器模式
    设计模式之 命令模式
    设计模式学习之 策略模式
  • 原文地址:https://www.cnblogs.com/a198720/p/4712760.html
Copyright © 2011-2022 走看看