BeetlSQL 研发自 2015 年,核心和生态扩展全部自研。目标是提供开发高效,维护高效,运行高效的数据访问框架,它适用范围广,定制性强,入门快。
阅读文档 源码和例子 在线体验 多库使用 性能测试 插件支持
本次发布
Fetch提供了新注解 @FetchMany2Many,实现类如@Build注解提供的FetchMany2ManyAction,能实现通过中间表获取对对多数据
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.METHOD, ElementType.FIELD})
@Builder(FetchMany2ManyAction.class)
public @interface FetchMany2Many {
//中间表对应的类名
Class tableClass();
String fromAttr();
String toAttr();
String enableOn() default "";
}
使用例子如下
@Table(name="sys_user")
public class MyUser {
@AutoID
Integer id;
String name;
@FetchMany2Many(tableClass = UserRole.class, fromAttr = "userId",toAttr ="roleId")
List<Role> roles;
}
BeetlSQL 核心功能
|
BeetlSQL 核心
|
功能
|
|
sql-core
|
核心包,封装了 JDBC 操作,SQL 文件管理,注解的注解管理
|
|
sql-fetch
|
类似 Hibernate 那样提供 @Fetch,@FetchMany 等注解
|
|
sql-mapper
|
mapper 类定义和扩展,用户可以自定义自己的 mapper 和 mapper 的注解
|
|
sql-intergration
|
整合 Spring,solon,jfinal 等框架,以及例子
|
|
sql-query
|
Query 和 LambdaQuery,用 Java API 构造和使用 SQL
|
|
sql-mapping
|
支持单表,多表与 POJO 的互相映射,支持 json 定义,xml 定义映射方式,或者约定习俗
|
|
sql-template
|
Beetl 模板实现,且支持其他模板语言
|
|
sql-gen
|
代码生成抽象包,并提供默认实现可以生成 dao,sql 文件,md 文档
|
|
sql-db-support
|
各种数据库的测试和验证,支持 33+ 数据库。
|
|
sql-samples
|
包含了上百个使用 beetlsql 的例子
|
|
sql-test
|
包含了上百个单元测试例子
|
BeetlSQL 最新扩展包
|
BeetlSQL 扩展包
|
功能
|
|
sql-xml
|
高仿 myabtis 的 xml 语法,如果喜欢使用 xml 写 sql 模板的,可以使用此扩展包
|
|
sql-accelerator
|
性能加速包,通过反射优化,缓存,让 beetlsql 性能提升 50%-200%,接近一半手写 JDBC 的性能
|
|
sql-firewall
|
sql 防火墙,避免不小心写的 sql 破坏数据库
|
|
sql-dynamic-table
|
支持像访问静态表格那样防火动态表格,简化动态创建表格的业务需求开发
|
|
sql-bean-encrypt
|
支持 @MD5 ,@AES 等对字段加密解密
|
|
sql-rewrite
|
采用 sql 重写,支持单表多租户模式,逻辑删除,数据权限功能
|
|
SAGA(实验)
|
BeetSQL 的 SAGA 是实现,用 SAGA 微服务事务
|
使用加速扩展性能优化结果:能达到近一半手写 JDBC 的性能
|
查询
|
测试内容
|
BeetlSQL(ops/ms)
|
纯 jdbc
|
mybatis
|
JPA
|
|
beetlsqlExecuteJdbc
|
直接执行 JDBC
|
318
|
678
|
/
|
64
|
|
beetlsqlExecuteTemplate
|
执行 SQL 模板
|
268
|
/
|
44
|
66
|
|
beetlsqlFile
|
SQL 存放在文件统一管理
|
266
|
/
|
41
|
/
|
|
beetlsqlInsert
|
插入一条
|
129
|
248
|
43
|
59
|
|
beetlsqlGetAll
|
获取所有数据
|
13
|
40
|
4
|
5
|
|
beetlsqlLambdaQuery
|
Java 函数编写 SQL 执行查询
|
196
|
/
|
9
|
/
|
|
beetlsqlPageQuery
|
翻页查询
|
159
|
/
|
17
|
59
|
|
beetlsqlSelectById
|
查询一条
|
259
|
670
|
43
|
61
|
JMH性能测试
Benchmark Mode Cnt Score Error Units
Beetl.addEntity thrpt 5 133.190 ± 38.548 ops/ms
Beetl.complexMapping thrpt 5 236.289 ± 288.370 ops/ms
Beetl.executeJdbcSql thrpt 5 298.657 ± 80.480 ops/ms
Beetl.executeTemplateSql thrpt 5 251.418 ± 77.757 ops/ms
Beetl.getAll thrpt 5 14.531 ± 0.605 ops/ms
Beetl.getEntity thrpt 5 359.275 ± 85.099 ops/ms
Beetl.lambdaQuery thrpt 5 187.228 ± 59.697 ops/ms
Beetl.one2Many thrpt 5 178.041 ± 181.829 ops/ms
Beetl.pageQuery thrpt 5 148.982 ± 39.327 ops/ms
Beetl.sqlFile thrpt 5 249.206 ± 100.083 ops/ms
DBVisitor.addEntity thrpt 5 99.294 ± 33.564 ops/ms
DBVisitor.executeJdbcSql thrpt 5 185.177 ± 50.993 ops/ms
DBVisitor.executeTemplateSql thrpt 5 3.189 ± 0.748 ops/ms
DBVisitor.getAll thrpt 5 3.163 ± 0.980 ops/ms
DBVisitor.getEntity thrpt 5 125.683 ± 44.190 ops/ms
DBVisitor.lambdaQuery thrpt 5 94.314 ± 38.499 ops/ms
DBVisitor.pageQuery thrpt 5 49.954 ± 18.254 ops/ms
EasyQuery.addEntity thrpt 5 98.904 ± 39.890 ops/ms
EasyQuery.complexMapping thrpt 5 67.397 ± 59.919 ops/ms
EasyQuery.executeJdbcSql thrpt 5 243.160 ± 48.080 ops/ms
EasyQuery.getAll thrpt 5 14.896 ± 2.219 ops/ms
EasyQuery.getEntity thrpt 5 134.370 ± 67.962 ops/ms
EasyQuery.lambdaQuery thrpt 5 137.292 ± 53.438 ops/ms
EasyQuery.one2Many thrpt 5 75.083 ± 53.738 ops/ms
EasyQuery.pageQuery thrpt 5 84.596 ± 46.942 ops/ms
Flex.addEntity thrpt 5 86.484 ± 40.022 ops/ms
Flex.getAll thrpt 5 2.926 ± 0.993 ops/ms
Flex.getEntity thrpt 5 73.445 ± 39.437 ops/ms
Flex.pageQuery thrpt 5 33.999 ± 26.776 ops/ms
Jdbc.addEntity thrpt 5 225.223 ± 304.585 ops/ms
Jdbc.executeJdbcSql thrpt 5 691.616 ± 145.280 ops/ms
Jdbc.getAll thrpt 5 35.827 ± 7.295 ops/ms
Jdbc.getEntity thrpt 5 678.791 ± 165.527 ops/ms
Jpa.addEntity thrpt 5 53.219 ± 78.543 ops/ms
Jpa.executeJdbcSql thrpt 5 60.734 ± 61.299 ops/ms
Jpa.executeTemplateSql thrpt 5 64.478 ± 48.688 ops/ms
Jpa.getAll thrpt 5 4.710 ± 2.062 ops/ms
Jpa.getEntity thrpt 5 56.325 ± 53.744 ops/ms
Jpa.one2Many thrpt 5 92.168 ± 111.591 ops/ms
Jpa.pageQuery thrpt 5 58.756 ± 48.056 ops/ms
MyBatis.addEntity thrpt 5 40.533 ± 12.461 ops/ms
MyBatis.complexMapping thrpt 5 106.348 ± 57.688 ops/ms
MyBatis.executeTemplateSql thrpt 5 46.953 ± 13.541 ops/ms
MyBatis.getAll thrpt 5 5.394 ± 0.502 ops/ms
MyBatis.getEntity thrpt 5 45.303 ± 11.928 ops/ms
MyBatis.lambdaQuery thrpt 5 23.756 ± 13.613 ops/ms
MyBatis.pageQuery thrpt 5 16.190 ± 5.682 ops/ms
MyBatis.sqlFile thrpt 5 42.558 ± 18.025 ops/ms
SqlUtils.addEntity thrpt 5 232.501 ± 332.656 ops/ms
SqlUtils.executeJdbcSql thrpt 5 682.610 ± 171.506 ops/ms
SqlUtils.getAll thrpt 5 44.353 ± 4.346 ops/ms
SqlUtils.getEntity thrpt 5 643.873 ± 131.587 ops/ms
Wood.addEntity thrpt 5 105.097 ± 79.961 ops/ms
Wood.executeJdbcSql thrpt 5 127.020 ± 48.142 ops/ms
Wood.executeTemplateSql thrpt 5 129.193 ± 44.455 ops/ms
Wood.getAll thrpt 5 2.051 ± 0.524 ops/ms
Wood.getEntity thrpt 5 126.104 ± 41.976 ops/ms
Wood.lambdaQuery thrpt 5 125.013 ± 43.991 ops/ms
Wood.pageQuery thrpt 5 220.101 ± 90.028 ops/ms
Wood.sqlFile thrpt 5 132.431 ± 50.141 ops/ms