1.student class
Package Com.test.hou.po;public class Student {private int sid;private String sname;private int sage;public int GetSID () {R Eturn SID;} public void Setsid (int sid) {this.sid = SID;} Public String Getsname () {return sname;} public void Setsname (String sname) {this.sname = sname;} public int getsage () {return sage;} public void setsage (int sage) {this.sage = sage;}}
2.StudentAction
Public String batchinsertstudent () {list<student> studentslist=new arraylist<student> (), for (int i = 0; i < 10; i++) {Student student=new Student (); Student.setsid (i); Student.setsname ("AA" +i); Student.setsage (I+10); Studentslist.add (student);} Studentservice.batchinsertstudent (studentslist); return "Batchinsertstudent";}
3.studentmapper.xml
<insert id= "batchinsertstudent" parametertype= "Java.util.List" >insert into student <foreach collection= " List "separator=" union All "item=" item "index=" Index "> (select #{item.sid},#{item.sname},#{item.sage}from Dual) </foreach></insert>
Note: SQL does not have values here, separator is union ALL and select----from dual
1. Pass the single parameter and be the list collection, collection as List
2. Flyer parameter and array, collection as array
3. Key with multi-parameter and Map,collectin as map
This article is from the "Big Talk Program" blog, please be sure to keep this source http://houqida.blog.51cto.com/8877896/1562410
Mybatis-oracle (Ssi2 frame) Bulk Increase