新增DAO批量更新语句,动态ExecutorType指定,新增 defaultBatchSize 批量分批默认大小设定
This commit is contained in:
@@ -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.Application;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 批量插入测试
|
||||
@@ -26,26 +24,23 @@ import com.jeesite.modules.test.entity.TestData;
|
||||
@ActiveProfiles("test")
|
||||
@SpringBootTest(classes=Application.class)
|
||||
public class InsertBatchTest extends BaseSpringContextTests {
|
||||
|
||||
|
||||
@Autowired
|
||||
private TestDataDao testDataDao;
|
||||
|
||||
@Test
|
||||
public void testData() throws Exception{
|
||||
public void testData1() throws Exception{
|
||||
List<TestData> list = ListUtils.newArrayList();
|
||||
for(int i=0; i<5000; i++){
|
||||
TestData testData = new TestData();
|
||||
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);
|
||||
list = testDataDao.findList(new TestData());
|
||||
System.out.println("size: " + list.size());
|
||||
System.out.println("insert: " + list.size());
|
||||
long count = testDataDao.updateBatch(list);
|
||||
System.out.println("update: " + count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user