MyBatis(二)批量插入insert语句拼接方式

<insert id="insertBatch" parameterType="java.util.List">
        insert into tbl_order_drivers_relation
            (order_code,
                driver_id,
                status,
                delivery_time,
                finish_time)
        values
        <foreach collection="list" item="it" separator=",">
            <trim prefix="(" suffix=")" suffixOverrides=",">
                    #{it.orderCode,jdbcType=VARCHAR},
                    #{it.driverId,jdbcType=VARCHAR},
                    #{it.status,jdbcType=VARCHAR},
                    #{it.deliveryTime,jdbcType=TIMESTAMP},
                    #{it.finishTime,jdbcType=TIMESTAMP},
            </trim>
        </foreach>

    </insert>

 

上一篇:用MyBatis三剑客实现一个简单的电商信息管理系统


下一篇:mybatis常用jdbcType数据类型与mysql的类型对照