千家信息网

mybatis-oracle(ssi2框架) 批量增加

发表于:2025-01-19 作者:千家信息网编辑
千家信息网最后更新 2025年01月19日,1.student类package com.test.hou.po;public class Student { private int sid; private Stri
千家信息网最后更新 2025年01月19日mybatis-oracle(ssi2框架) 批量增加

1.student类

package com.test.hou.po;public class Student {        private int sid;        private String sname;        private int sage;        public int getSid() {                return 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 studentslist=new ArrayList();                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 into student  (select #{item.sid},#{item.sname},#{item.sage}from dual)

注意:此处sql没有values, separator 为union all和select ----from dual

1.传递单参数且为list集合,collection 为list

2.传单参数且为数组,collection为array

3.传多参数且为map,collectin 为map的key

0