1.oracle中批处理方式
<insert id="insertBatch" parameterType="java.util.List"> 2 BEGIN 3 <foreach collection="list" item="item" index="index" separator=";" > 4 INSERT INTO TABLE.STUDENT (ID,AGE,NAME,STU_ID) VALUES 5 ( DEMO.SEQ_EID.NEXTVAL,#{item.age},#{item.name},#{item.stuId} ) 6 </foreach> 7 ;END ;8 </insert>
2.MySQL中批处理
<insert id="insertBatch"> insert into student ( <include refid="Base_Column_List"/> ) values <foreach collection="list" item="item" index="index" separator=","> (null,#{item.name},#{item.sex},#{item.address},#{item.telephone},#{item.tId}) </foreach> </insert>