一:使用map封装,这种方法使用于前端传值过来,然后封装批量插入
1:先创建对象
Map<String,Object> map = new HashMap<>();
Map<String, Object> params = new HashMap<>();
Test test = new Test();
test.setName("wawawa");
test.setAge("17");
2:将对象插入到map中,这里因为要在xml中取值,需要加一层封装
Long start = new Date().getTime();
for (int i=0;i<10000;i++){
map.put(""+i,test);
}
params.put("keys",map);
lmLoanService.save(params);
Long end = new Date().getTime();
System.out.println((end-start)/1000);
3:xml写法
<insert id="save" parameterType="hashmap">
INSERT INTO 表名 (name,age) VALUES
<foreach collection="keys" index=