转载自:http://blog.csdn.net/yuguiyang1990/article/details/8764043
从网上查阅相关资料,整理了一个Oracle批量插入的方法:
<insert id="insertBatch" parameterType="ArrayList" useGeneratedKeys="true">
<selectKey keyProperty="deptno" order="BEFORE" resultType="int">
SELECT S_FORUM_USERID.NEXTVAL FROM DUAL
</selectKey>
INSERT INTO DEPT(DEPTNO , DNAME , LOC) SELECT S_FORUM_USERID.NEXTVAL , A.* FROM (
<foreach collection="list" item="item" index="index" separator="UNION">
SELECT #{item.dname} , #{item.loc} FROM DUAL
</foreach>
) A
</insert>
来源自:http://doufuguolyl.iteye.com/blog/1998669
<insert id="batchInsert" parameterType="java.util.List">
insert into DATA (ID, TEXT, STAUTS)
<foreach close=")" collection="list" item="item" index="index" open="(" separator="union">
select
#{item.id,jdbcType=VARCHAR},
#{item.text,jdbcType=VARCHAR},
#{item.stauts,jdbcType=VARCHAR}
from dual
</foreach>
</insert>
第二种方式,使用起来速度更快点。