Mybatis内批量插入Oracle

<insert id="insertManagerInfoBatch" parameterType="java.util.List">
        <selectKey resultType="java.math.BigDecimal" order="BEFORE" keyProperty="id">
            SELECT XSHTEST.XSHE_BRANCH_OFFICE_SEQ.Nextval as ID from DUAL
        </selectKey>
        insert into xshtest.XSHE_CUSTOMER_MANAGER
        (id,manager_name,manager_no,branch_company_id,contact_phone,status)
        SELECT XSHTEST.XSHE_BRANCH_OFFICE_SEQ.Nextval ,t.* FROM (
        <foreach collection="list" item="item" separator="UNION ALL">
            select
            #{item.managerName},
            #{item.managerNo},
            #{item.companyId},
            #{item.contactPhone},
            #{item.status}
            from dual
        </foreach>
        )t
    </insert>
/**
 *mapper传参为list
 **/
 int insertManagerInfoBatch(List list);

不要忘记对序列赋权:grant select on XSHE_BRANCH_OFFICE_SEQ to user

原文地址:https://www.cnblogs.com/SimonHu1993/p/10025193.html