springboot整合mybatis批量插入数据至Mysql

  • Post author:
  • Post category:mysql


xml中sql语句如下:

<insert id="batchAdd" parameterType="java.util.List">
        insert into CW_PER_CON_TEMPLATES_COLS(ID, TEMPLATE_ID, CONDITON_NAME, LABEL_CODE, OPERATION,
        CONDITION_VALUE, SORT, SYSTEM_ID, CREATE_TIME, CREATE_USER_ID, LAST_UPDATE_TIME,
        LAST_UPDATE_USER_ID, DEL_FLAG, REMARKS)
        values
        <foreach collection="list" index="index" item="item" open="(" separator="),(" close=")">
            #{item.conditionId, jdbcType = BIGINT},       #{item.templateId, jdbcType = BIGINT},
            #{item.conditionName, jdbcType = VARCHAR},    #{item.labelCode, jdbcType = VARCHAR},
            #{item.operation, jdbcType = VARCHAR},        #{item.conditionValue, jdbcType = VARCHAR},
            #{item.sort, jdbcType = INTEGER},             #{item.systemId, jdbcType = BIGINT},
            #{item.createTime, jdbcType = BIGINT},        #{item.createUserId, jdbcType = VARCHAR},
            #{item.lastUpdateTime, jdbcType = BIGINT},    #{item.lastUpdateUserId, jdbcType = VARCHAR},
            #{item.delFlag, jdbcType = VARCHAR},          #{item.remarks, jdbcType = VARCHAR}
        </foreach>
    </insert>



版权声明:本文为wangchaox123原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。