springboot整合mybatis批量插入数据至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>

猜你喜欢

转载自blog.csdn.net/wangchaox123/article/details/93208707