日期:2014-05-16  浏览次数:20704 次

Mybatis批量插入oracle,mysql
oracle


<insert id="addUserData" parameterType="java.util.List">
	INSERT INTO T_P_USER_DATA (USER_ID, DEPART_ID)
	<foreach collection="list" item="item" index="index" separator=" UNION ALL ">  
    SELECT #{item.userId}, #{item.departId} FROM DUAL
	</foreach>  
</insert>



mysql


<insert id="addUserData" parameterType="java.util.List">
	INSERT INTO T_P_USER_DATA (USER_ID, DEPART_ID)
	VALUES <foreach collection="list" item="item" index="index"  
    separator=",">  
    ( #{item.userId}, #{item.departId})  
	</foreach>  
</insert>