liteBatch轻量级的高性能批插框架

联合创作 · 2023-09-30 20:39

liteBatch 是一个轻量级,高性能,高通用的批插框架。

  • 能够像普通 insert 一样在循环中插入 PO

  • 支持数据库和文件批插2种模式

  • 异步执行,无阻塞

  • 可以和各种 ORM 结合使用

  • 提供对 spring 的支持

  • 兼容各种数据库

  • 适应所有的 VO ,自动生成脚本

  • 性能高效,测试机上测试大概4w+/秒

  • 自动处理各种基础类型的数据

  • 支持自定义的映射和过滤字段

Quick Start

也可以参考 test 工程的 testUnit

	try {
		Random random = new Random();
		Person person = null;
		for (int i = 0; i < 100300; i++) {
			person = new Person();
			person.setAge(random.nextInt(100));
			person.setAddress("XX马路"+random.nextInt(100)+"号");
			person.setCompany("天天 向上科技有限公司");
			person.setName("张三");
			person.setCreateTime(new Date());
			rowBatchListener.insertOneWithBatch(person);
		}
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		rowBatchListener.flush();
	}
	<bean id="rowBatchListener"  class="com.thebeastshop.batch.spring.RowBatchListenerFactoryBean">
		<property name="jdbcTemplate" ref="jdbcTemplate"/>
		<property name="submitCapacity" value="5000"/>
		<property name="beanClass" value="com.thebeastshop.batch.test.Person"/>
		<!--<property name="syn" value="true"/>默认为false,推荐采用false,打开的话,则为同步模式-->
	</bean>

注意

在mysql数据库下,需要注意以下几点

  • 驱动包一定得5.1.13版本以上(含)

  • 在jdbc连接url里得加上rewriteBatchedStatements=true参数

浏览 4
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报