新增DAO批量更新语句,动态ExecutorType指定,新增 defaultBatchSize 批量分批默认大小设定
This commit is contained in:
@@ -702,6 +702,9 @@ mybatis:
|
||||
#
|
||||
# # 是否开启 JDBC 管理事务,默认 Spring 管理事务 v4.2.3
|
||||
# jdbcTransaction: false
|
||||
#
|
||||
# # 批量插入和更新的分批默认大小(防止库一次性接受不了太大的sql语句)
|
||||
# defaultBatchSize: 500
|
||||
|
||||
# Mapper文件刷新线程
|
||||
mapper:
|
||||
|
||||
@@ -4,19 +4,17 @@
|
||||
*/
|
||||
package com.jeesite.test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import com.jeesite.common.callback.MethodCallback;
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.tests.BaseSpringContextTests;
|
||||
import com.jeesite.modules.ApiApplication;
|
||||
import com.jeesite.modules.test.dao.TestDataDao;
|
||||
import com.jeesite.modules.test.entity.TestData;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量插入测试
|
||||
@@ -38,14 +36,11 @@ public class InsertBatchTest extends BaseSpringContextTests {
|
||||
testData.setTestInput("test"+i);
|
||||
list.add(testData);
|
||||
}
|
||||
ListUtils.pageList(list, 100, new MethodCallback() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object execute(Object... objs) {
|
||||
return testDataDao.insertBatch((List<TestData>)objs[0]);
|
||||
}
|
||||
});
|
||||
testDataDao.insertBatch(list, null);
|
||||
list = testDataDao.findList(new TestData());
|
||||
System.out.println("size: " + list.size());
|
||||
System.out.println("insert: " + list.size());
|
||||
long count = testDataDao.updateBatch(list, null);
|
||||
System.out.println("update: " + count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user