public class LazyTest {
public static void main(String[] args) {
LazyLambdaStream lazyLambdaStream = LazyLambdaStreamFactory.createLazyLambdaStream("127.0.0.1", 3306, "compare_orm", "root", "wujiawei");
DynamicLazyDataSourceTypeHolder.push(LazyDataSourceType.MySQL);
// 清空数据
lazyLambdaStream.delete(LazyWrappers.<SysUserDO>lambdaWrapper().notNull(SysUserDO::getId));
StopWatch stopWatch = new StopWatch("Lazy ORM 执行数据操作");
// 10 的幂数
int power = 5;
// 执行批量插入
int size = 10;
for (int i = 0; i < power; i++) {
stopWatch.start("批量新增数据:" + size);
lazyLambdaStream.upsert(DataTransformUntil.simulationBeanList(SysUserDO.class, size));
stopWatch.stop();
size = size * 10;
}
int pageSize = 10;
// 执行 查询
for (int i = 0; i < power; i++) {
stopWatch.start("批量分页查询数据:" + pageSize);
lazyLambdaStream.selectPage(LazyWrappers.<SysUserDO>lambdaWrapperBean(new SysUserDO()), LazyPage.of(1, pageSize));
pageSize = pageSize * 10;
stopWatch.stop();
}
String s = stopWatch.prettyPrint();
System.out.println(s);
}
}
【非spring 项目使用Lazy ORM 框架】进行数据批量插入和分页查询
于 2024-03-01 23:00:03 首次发布