Main(){
List<DeptInfo> depts = new ArrayList<DeptInfo>();
depts.add(new DeptInfo("s01", "GGG"));
depts.add(new DeptInfo("s02", "GGG"));
depts.add(new DeptInfo("s03", "GGG"));
depts.add(new DeptInfo("s04", "GGG"));
session.insert("com.zr.day_28.model.DeptInfo.batchadd", depts);
}
<insert id="batchadd" parameterType="java.util.List">
insert into deptInfo(deptId,deptName)
<foreach collection="list" index="index" item="item" separator="union" close=")" open="(">
select
#{item.deptid},#{item.deptname}
from dual
</foreach>
</insert>