MyBatis批量插入(Oracle数据库)

从网上查阅相关资料,整理了一个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>

你可能感兴趣的:(mybatis,批量插入)