zoukankan      html  css  js  c++  java
  • xml中批量新增数据或者批量修改数据

    批量提交多条语句需要在 mysql 的连接里面开启 allowMultiQueries=true
    如:url: jdbc:mysql://127.0.0.1:3306/ku?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true

    <insert id="batchInsert" parameterType="com.Entity">
        insert into pos_parameter ( store_id, pos_id,
        parameter_id, parameter_name, parameter_value,
        parameter_desc, parameter_type, is_show,
        is_modify, create_user_id, memo,
        created_time, updated_time)
        values
      <foreach collection="list"  item="param" index="index" separator=",">
        ( #{param.storeId,jdbcType=VARCHAR}, #{param.posId,jdbcType=VARCHAR},
        #{param.parameterId,jdbcType=VARCHAR}, #{param.parameterName,jdbcType=VARCHAR}, #{param.parameterValue,jdbcType=VARCHAR},
        #{param.parameterDesc,jdbcType=VARCHAR}, #{param.parameterType,jdbcType=INTEGER}, #{param.isShow,jdbcType=CHAR},
        #{param.isModify,jdbcType=CHAR}, #{param.createUserId,jdbcType=VARCHAR}, #{param.memo,jdbcType=VARCHAR},
        #{param.createdTime,jdbcType=TIMESTAMP}, #{param.updatedTime,jdbcType=TIMESTAMP})
      </foreach>
    </insert>
    <update id="batchUpdate" parameterType="com.Entity">
      <foreach item="param" collection="list" separator=";" index="index">
        update pos_parameter
        <set>
          <if test="param.storeId != null">
            store_id = #{param.storeId,jdbcType=VARCHAR},
          </if>
          <if test="param.posId != null">
            pos_id = #{param.posId,jdbcType=VARCHAR},
          </if>
          <if test="param.parameterId != null">
            parameter_id = #{param.parameterId,jdbcType=VARCHAR},
          </if>
          <if test="param.parameterName != null">
            parameter_name = #{param.parameterName,jdbcType=VARCHAR},
          </if>
          <if test="param.parameterValue != null">
            parameter_value = #{param.parameterValue,jdbcType=VARCHAR},
          </if>
          <if test="param.parameterDesc != null">
            parameter_desc = #{param.parameterDesc,jdbcType=VARCHAR},
          </if>
          <if test="param.parameterType != null">
            parameter_type = #{param.parameterType,jdbcType=INTEGER},
          </if>
          <if test="param.isShow != null">
            is_show = #{param.isShow,jdbcType=CHAR},
          </if>
          <if test="param.isModify != null">
            is_modify = #{param.isModify,jdbcType=CHAR},
          </if>
          <if test="param.createUserId != null">
            create_user_id = #{param.createUserId,jdbcType=VARCHAR},
          </if>
          <if test="param.memo != null">
            memo = #{param.memo,jdbcType=VARCHAR},
          </if>
          <if test="param.createdTime != null">
            created_time = #{param.createdTime,jdbcType=TIMESTAMP},
          </if>
          <if test="param.updatedTime != null">
            updated_time = #{param.updatedTime,jdbcType=TIMESTAMP},
          </if>
        </set>
        where id = #{param.id,jdbcType=BIGINT}
      </foreach>
    </update>



  • 相关阅读:
    Linux操作系统基础(完结)
    单台主机上DB2 10.5和arcgis 10.4 空间数据库配置
    java连接oracle数据库使用SERVICE NAME、SID以及TNSName不同写法
    arcgis desktop 地理编码服务发布
    利用arcgis发布综合又详细的地理定位服务
    centos 安装arcgis server 10.1
    spark源代码
    bootstrap.memory_lock: true导致Elasticsearch启动失败问题
    安装jdk后出现bash: ./java: /lib/ld-linux.so.2: bad ELF interpreter: 没有那个文件或目录
    pyspark采用python3开发
  • 原文地址:https://www.cnblogs.com/ding08/p/11686309.html
Copyright © 2011-2022 走看看