实现方案一:
<!-- 使用sql 实现 -->
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false" >
INSERT INTO WF_TASKTEMP_DEALSTAFF (DEAL_ID, TEMP_ID, STAFF_ID,DEAL_TYPE, STATUS)
SELECT WF_TASKTEMP_DEALSTAFF$SEQ.NEXTVAL,a.* FROM (
<foreach collection="list" item="item" separator="union all">
SELECT
#{item.tempId,jdbcType=VARCHAR},
#{item.staffId,jdbcType=VARCHAR},
#{item.dealType,jdbcType=VARCHAR},
#{item.status,jdbcType=CHAR}
FROM dual
</foreach>
) a
</insert>
实现方案二:
<!-- 使用存储过程实现 -->
<insert id="insertBatch1" parameterType="java.util.List">
begin
<foreach collection="list" item="item" index="index">
insert into WF_TASKTEMP_DEALSTAFF
(
DEAL_ID, TEMP_ID, STAFF_ID,DEAL_TYPE, STATUS
)
values(WF_TASKTEMP_DEALSTAFF$SEQ.nextval,
#{item.tempId,jdbcType=VARCHAR},
#{item.staffId,jdbcType=VARCHAR},
#{item.dealType,jdbcType=VARCHAR},
#{item.status,jdbcType=CHAR}
);
</foreach>
end;
</insert>