
MyBatis-Flex: 一个优雅的 MyBatis 增强框架
特征
1、很轻量
MyBatis-Flex 整个框架只依赖 MyBatis,再无其他任何第三方依赖。
2、只增强
MyBatis-Flex 支持 CRUD、分页查询、多表查询、批量操作,但不丢失 MyBatis 原有的任何功能。
3、高性能
MyBatis-Flex 采用独特的技术架构、相比许多同类框架,MyBatis-Flex 的在增删改查等方面的性能均超越其 5~10 倍或以上。
4、更灵动
MyBatis-Flex 支持多主键、多表查询、逻辑删除、乐观锁、数据脱敏、数据加密、多数据源、分库分表、字段权限、 字段加密、多租户、事务管理、SQL 审计... 等等等等。 这一切,免费且灵动。
在 MyBatis-Flex v1.7.2 中,受诸多用户的要求下,我们新增了对 MyBatis-Plus 的 QueryWrapper 兼容 API,方便喜欢 MyBatis-Flex 的用户从 MyBatis-Plus 迁移到 MyBatis-Flex。
以下是一些兼容 API 的示例:
QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.from("tb_account") .eq("column1", "value1") .ge(Account::getAge, 18) .or(wrapper -> { wrapper.eq("column2", "value2") .ge(Account::getSex, 0); }); System.out.println(queryWrapper.toSQL());
其生成的 SQL 如下:
SELECT * FROM `tb_account` WHERE column1 = 'value1' AND `age` >= 18 OR (column2 = 'value2' AND `sex` >= 0)
虽然 MyBatis-Flex 尽量兼容 MyBatis-Plus 的 API,但细节也有所不同,更多参考:https://mybatis-flex.com/zh/base/querywrapper.html#mybatis-plus-%E5%85%BC%E5%AE%B9-api
MyBatis-Flex v1.7.2 更新细节如下:
- 新增:QueryWrapper 添加对 MyBatis-Plus 的兼容 API,方便喜欢 MyBatis-Flex 的用户进行迁移
- 新增:QueryModel #select()方法 添加 Iterable queryColumns,感谢 @关梦园
- 新增:QueryWrapper 添加 RawQueryTable 的支持,感谢 @王帅
- 新增:RelationToOne 注解添加对 extraCondition 配置的支持 #I88MJU:[Bug]: 一对多的问题
- 新增:重构 DynamicSchemaProcessor,添加 table 参数,方便通过 table 获取 schema #I88REA:[使用问题]: 动态 schema 和 动态表名问题
- 优化:在 insert 时,若 entity 有主键,则直接使用 entity 的主键,不再通过主键生成器来生成 #I88TX1:[功能建议]: insert时,主键的设置
- 优化:RelationManager 前置数据源的设置,否则关联查询注解可能造成数据源设置冲突
- 修复:使用 Db 无法使用指定 Logger 打印日志问题,感谢 @Aohan-Zhang #I88C41:[使用问题]: 配置了日志实现类,但是控制台没有打出sql日志
- 修复:MyBatis-Flex 与 spring-data-jpa 混用时候,出现事务管理器冲突错误的问题,感谢 @lcxw
- 修复:CPI.setWhereQueryCondition 传入 null 时,出现 NPE 的问题 #I88DFH:[Bug]: 使用CPI.setWhereQueryConditon时,无法按照预期正确的设置。
- 修复:代码生成器未做自定义配置时,生成代码时出现 NPE 的问题 #I88UIZ:[Bug]: 代码生成器生成代码时报空指针异常
- 测试:为测试添加更多的断言已保证测试安全
- 文档:QueryWrapper 添加关于自定义字符串列名的相关文档
- 文档:QueryWrapper 添加关于 MyBatis-Plus 兼容 API 的相关文档
- 文档:QueryWrapper 添加关于 Map 转化为 QueryWrapper 的相关文档
代码贡献者,请参考:https://mybatis-flex.com/zh/intro/what-is-mybatisflex.html#%E8%B4%A1%E7%8C%AE%E8%80%85
进一步了解 MyBatis-Flex 框架,请参考一下链接:
- 1、快速开始:https://mybatis-flex.com/zh/intro/getting-started.html
- 2、多表关联查询:https://mybatis-flex.com/zh/base/query.html
- 3、一对多、多对一:https://mybatis-flex.com/zh/base/relations-query.html
- 4、灵活的 QueryWrapper:https://mybatis-flex.com/zh/base/querywrapper.html
- 5、逻辑删除:https://mybatis-flex.com/zh/core/logic-delete.html
- 6、乐观锁:https://mybatis-flex.com/zh/core/version.html
- 7、数据填充:https://mybatis-flex.com/zh/core/fill.html
- 6、数据脱敏:https://mybatis-flex.com/zh/core/mask.html
- 7、SQL 审计:https://mybatis-flex.com/zh/core/audit.html
- 8、多数据源:https://mybatis-flex.com/zh/core/multi-datasource.htm
- 9、数据源加密:https://mybatis-flex.com/zh/core/datasource-encryption.html
- 10、动态表名:https://mybatis-flex.com/zh/core/dynamic-table.html
- 11、事务管理:https://mybatis-flex.com/zh/core/tx.html
- 12、数据权限:https://mybatis-flex.com/zh/core/data-permission.html
- 13、字段权限:https://mybatis-flex.com/zh/core/columns-permission.html
- 14、字段加密:https://mybatis-flex.com/zh/core/columns-encrypt.html
- 15、字典回写:https://mybatis-flex.com/zh/core/columns-dict.html
- 16、枚举属性:https://mybatis-flex.com/zh/core/enum-property.html
- 17、多租户:https://mybatis-flex.com/zh/core/multi-tenancy.html
- 18、代码生成器:https://mybatis-flex.com/zh/others/codegen.html
- 19、QQ 交流群:https://mybatis-flex.com/zh/intro/qq-group.html
- 20、更好用的功能正在路上:https://mybatis-flex.com
bilibili 视频教程(免费):
课程 1:《MyBatis-Flex 视频教程》
课程简介:该课程由 王帅 老师录制主讲, 王帅 老师也是除了作者以外,对 MyBatis-Flex 代码贡献最大的 committer。 其无论对 MyBatis 还是 MyBatis-Flex,都有非常深入的理解。
课程地址:
https://www.bilibili.com/video/BV11h411A7cU
课程 2:《MyBatis-Flex 轻松掌握,从零基础到高级应用的完整教程!持续更新中~》
课程简介:该课程由周游老师录制,周游老师有多年的开发经验以及丰富的教学经验,能够把 MyBatis-Flex 的许多原理知识讲解的通俗易懂、深入浅出。
课程地址:
https://www.bilibili.com/video/BV1kF411r7ky
另外,MyBatis-Flex 团队的另外开源两个 React 高级组件,用到的同学也可以关注下:
- Antd-bpmn:一个基于 React + Ant.design + bpmn.js 编写的工作流高阶组件,开源网址:https://gitee.com/antdadmin/antd-bpmn
- Antd-crud:一个优质的 React 【增删改查】高阶组件,基于 Ant.Design。开源网址:https://gitee.com/antdadmin/antd-crud
还没有评论,来说两句吧...