diff --git a/changes.md b/changes.md
index 549a083c..55713753 100644
--- a/changes.md
+++ b/changes.md
@@ -1,6 +1,34 @@
# MyBatis-Flex ChangeLog
+## v1.5.7 20230812:
+- 新增:QueryWrapper 添加对 delete 和 update 的 left join 支持
+- 新增:RelationManager.addIgnoreRelations() 添加对 lambda 的支持
+- 新增:添加 QueryColumnBehavior 用于自定义 QueryColumn 的某些行为特征
+- 新增:typeHandler 添加对泛型自动支持的功能
+- 新增:多数据源新增对 Seata 分布式事务的支持,感谢 @lifejwang11
+- 新增:添加对 Kotlin 的扩展支持,感谢 @kamo-sama
+- 新增:添加 saveOrUpdateBatch 方法的支持,感谢 @Suomm
+- 新增:QueryModel 提供 as 方法的支持,感谢 @Suomm
+- 新增:逻辑删除、乐观锁、多租户添加全局默认自动配置的功能,感谢 @Suomm
+- 优化:移除 flex 自动把 id 属性设置为主键的功能
+- 优化:重构链式调用的方法,统一链式调用和 ActiveRecord 的 API,感谢 @Suomm
+- 优化:UpdateChian 支持设置 left join 的表数据的支持,感谢 @Suomm
+- 修复:db2 方言的 KeywordWrap 错误的问题
+- 修复:在某些场景下 count 查询没有被替换的问题,感谢 @Suomm
+- 修复:QueryWrapper 的 or(consumer, condition) 方法逻辑错误,感谢 @Suomm
+- 修复:QueryColumn 由于 Predicate 没有类型约束可能导致类型转换异常的问题,感谢 @Suomm
+- 修复:OSGI 环境下,Lambda 通过 ClassLoader 获取不到类的问题,感谢 @2han9wen71an
+- 文档:更新视频教程的文档链接
+- 文档:添加 SpringBoot 最低版本的说明文档,感谢 @Suomm
+- 文档:Seata 分布式事务的相关文档,感谢 @lifejwang11
+- 文档:增加了使用gradle构建时的文档说明,感谢 @CloudPlayer
+- 文档:增加了在Kotlin中使用注解处理器的说明,感谢 @CloudPlayer
+- 文档:常见问题添加代码生成器获取不到注释说明,感谢 @Suomm
+- 文档:常见问题添加 Spring Devtools 造成的类转换异常的相关文档
+- 文档:常见问题添加 Nacos 集成启动出错的相关文档
+
+
## v1.5.6 20230804:
- 新增:代码生成器重构并新增对 Solon 框架的代码生成功能,感谢 @Suomm
diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts
index 238c4834..af2d6832 100644
--- a/docs/.vitepress/config.ts
+++ b/docs/.vitepress/config.ts
@@ -46,6 +46,7 @@ export default defineConfig({
{text: 'MyBatis-Flex 是什么', link: '/zh/intro/what-is-mybatisflex'},
{text: '快速开始', link: '/zh/intro/getting-started'},
{text: 'Maven 依赖', link: '/zh/intro/maven'},
+ {text: 'Gradle 依赖', link: '/zh/intro/gradle'},
{text: '和同类框架「功能」对比', link: '/zh/intro/comparison'},
{text: '和同类框架「性能」对比', link: '/zh/intro/benchmark'},
{text: '使用 Mybatis 原生功能', link: '/zh/intro/use-mybatis-native'},
@@ -100,6 +101,7 @@ export default defineConfig({
items: [
{text: '代码生成器', link: '/zh/others/codegen'},
{text: 'APT 设置', link: '/zh/others/apt'},
+ {text: 'KAPT 设置', link: '/zh/others/kapt'},
]
}
],
diff --git a/docs/.vitepress/theme/MyLayout.vue b/docs/.vitepress/theme/MyLayout.vue
index 14767443..7fb3b5cf 100644
--- a/docs/.vitepress/theme/MyLayout.vue
+++ b/docs/.vitepress/theme/MyLayout.vue
@@ -115,7 +115,7 @@ const {Layout} = DefaultTheme
- 虚以待位
+
diff --git a/docs/assets/images/ad/topiam_20230909.png b/docs/assets/images/ad/topiam_20230909.png
new file mode 100644
index 00000000..ba5d768d
Binary files /dev/null and b/docs/assets/images/ad/topiam_20230909.png differ
diff --git a/docs/index.md b/docs/index.md
index 4270ba51..6e496041 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -20,7 +20,7 @@ features:
- title: 更轻量
details: MyBatis-Flex 除了 MyBatis 本身,再无任何第三方依赖,因此会带来更高的自主性、把控性和稳定性。在任何一个系统中,依赖越多,稳定性越差。
- title: 更灵活
- details: MyBatis-Flex 提供了非常灵活的 QueryWrapper,支持关联查询、多表查询、多主键、逻辑删除、乐观锁更新、数据填充、数据脱敏、等等....
+ details: MyBatis-Flex 提供了非常灵活的 QueryWrapper,支持关联查询、多表查询、多主键、逻辑删除、乐观锁更新、数据填充、数据脱敏等等。
- title: 更高的性能
details: MyBatis-Flex 通过独特的架构,没有任何 MyBatis 拦截器、在 SQL 执行的过程中,没有任何的 SQL Parse,因此会带来指数级的性能增长。
---
diff --git a/docs/zh/awesome-things.md b/docs/zh/awesome-things.md
index d6812ffe..550cd13e 100644
--- a/docs/zh/awesome-things.md
+++ b/docs/zh/awesome-things.md
@@ -87,6 +87,10 @@
- [MyBatis-Flex 视频教程 - 33 关联查询(Field Query)](https://www.bilibili.com/video/BV17k4y1g7vt)
- [MyBatis-Flex 视频教程 - 34 关联查询(Relation Query)](https://www.bilibili.com/video/BV1bj411r7A4)
- [MyBatis-Flex 视频教程 - 35 关联查询对比](https://www.bilibili.com/video/BV1oF411f7dr)
+- [MyBatis-Flex 视频教程 - 36 分页查询](https://www.bilibili.com/video/BV1d44y1F7JM)
+- [MyBatis-Flex 视频教程 - 37 分页查询 count 查询优化](https://www.bilibili.com/video/BV1np4y1G7R9)
+- [MyBatis-Flex 视频教程 - 38 基于 XML 文件的高性能分页](https://www.bilibili.com/video/BV1Zh4y1D7aj)
+- [MyBatis-Flex 视频教程 - 39 Db + Row](https://www.bilibili.com/video/BV1wp4y1g7by)
diff --git a/docs/zh/base/configuration.md b/docs/zh/base/configuration.md
index 903f144d..f40859e5 100644
--- a/docs/zh/base/configuration.md
+++ b/docs/zh/base/configuration.md
@@ -8,13 +8,15 @@ SpringBoot 配置文件(`application.yml` 等)主要是用于对 MyBatis 原
mybatis-flex:
#......
datasource:
- #......
+ #......
configuration:
- #......
+ #......
global-config:
- #......
+ #......
admin-config:
- #......
+ #......
+ seata-config:
+ #......
```
## mybatis-flex
@@ -129,7 +131,28 @@ TypeHandler 扫描路径,如果配置了该属性,SqlSessionFactoryBean 会
- 类型:`java.lang.Object`
- 默认值:`1`
-逻辑删除数据删除标记值,
+逻辑删除数据删除标记值。
+
+### logic-delete-column
+
+- 类型:`java.lang.String`
+- 默认值:`del_flag`
+
+默认的逻辑删除字段。
+
+### tenant-column
+
+- 类型:`java.lang.String`
+- 默认值:`tenant_id`
+
+默认的多租户字段。
+
+### version-column
+
+- 类型:`java.lang.String`
+- 默认值:`version`
+
+默认的乐观锁字段。
## admin-config
@@ -152,4 +175,20 @@ MyBatis-Flex-Admin 连接端点。
- 类型:`String`
- 默认值:`null`
-MyBatis-Flex-Admin 连接密钥。
\ No newline at end of file
+MyBatis-Flex-Admin 连接密钥。
+
+## seata-config
+
+### enable
+
+- 类型:`boolean`
+- 默认值:`false`
+
+是否启用 Seata 代理数据源。
+
+### seata-mode
+
+- 类型:`com.mybatisflex.spring.boot.MybatisFlexProperties.SeataMode`
+- 默认值:`AT`
+
+使用 Seata AT 模式代理数据源。
diff --git a/docs/zh/base/querywrapper.md b/docs/zh/base/querywrapper.md
index 9c003f13..7c4346dc 100644
--- a/docs/zh/base/querywrapper.md
+++ b/docs/zh/base/querywrapper.md
@@ -1017,7 +1017,7 @@ QueryWrapper query2 = QueryWrapper.create()
在以上的 `query1` 中,由于 `userName` 和 `id` 都为 null,MyBatis-Flex 会自动忽略 null 值的条件,因此,它们构建出来的 SQL 条件是和 `query2` 完全一致的 。
-## QueryColumnBehavior
+## QueryColumnBehavior
在以上的内容中,我们知道 MyBatis-Flex 会自动忽略 `null` 值的条件,但是在实际开发中,有的开发者希望除了自动忽略 `null`
值以外,还可以自动忽略其他值,比如 `空字符串` 等。
diff --git a/docs/zh/changes.md b/docs/zh/changes.md
index 549a083c..55713753 100644
--- a/docs/zh/changes.md
+++ b/docs/zh/changes.md
@@ -1,6 +1,34 @@
# MyBatis-Flex ChangeLog
+## v1.5.7 20230812:
+- 新增:QueryWrapper 添加对 delete 和 update 的 left join 支持
+- 新增:RelationManager.addIgnoreRelations() 添加对 lambda 的支持
+- 新增:添加 QueryColumnBehavior 用于自定义 QueryColumn 的某些行为特征
+- 新增:typeHandler 添加对泛型自动支持的功能
+- 新增:多数据源新增对 Seata 分布式事务的支持,感谢 @lifejwang11
+- 新增:添加对 Kotlin 的扩展支持,感谢 @kamo-sama
+- 新增:添加 saveOrUpdateBatch 方法的支持,感谢 @Suomm
+- 新增:QueryModel 提供 as 方法的支持,感谢 @Suomm
+- 新增:逻辑删除、乐观锁、多租户添加全局默认自动配置的功能,感谢 @Suomm
+- 优化:移除 flex 自动把 id 属性设置为主键的功能
+- 优化:重构链式调用的方法,统一链式调用和 ActiveRecord 的 API,感谢 @Suomm
+- 优化:UpdateChian 支持设置 left join 的表数据的支持,感谢 @Suomm
+- 修复:db2 方言的 KeywordWrap 错误的问题
+- 修复:在某些场景下 count 查询没有被替换的问题,感谢 @Suomm
+- 修复:QueryWrapper 的 or(consumer, condition) 方法逻辑错误,感谢 @Suomm
+- 修复:QueryColumn 由于 Predicate 没有类型约束可能导致类型转换异常的问题,感谢 @Suomm
+- 修复:OSGI 环境下,Lambda 通过 ClassLoader 获取不到类的问题,感谢 @2han9wen71an
+- 文档:更新视频教程的文档链接
+- 文档:添加 SpringBoot 最低版本的说明文档,感谢 @Suomm
+- 文档:Seata 分布式事务的相关文档,感谢 @lifejwang11
+- 文档:增加了使用gradle构建时的文档说明,感谢 @CloudPlayer
+- 文档:增加了在Kotlin中使用注解处理器的说明,感谢 @CloudPlayer
+- 文档:常见问题添加代码生成器获取不到注释说明,感谢 @Suomm
+- 文档:常见问题添加 Spring Devtools 造成的类转换异常的相关文档
+- 文档:常见问题添加 Nacos 集成启动出错的相关文档
+
+
## v1.5.6 20230804:
- 新增:代码生成器重构并新增对 Solon 框架的代码生成功能,感谢 @Suomm
diff --git a/docs/zh/core/tx.md b/docs/zh/core/tx.md
index 084370e0..2867f664 100644
--- a/docs/zh/core/tx.md
+++ b/docs/zh/core/tx.md
@@ -224,8 +224,14 @@ public void purchase(String userId, String commodityCode, int orderCount) {
> 的官方示例快速开始:https://seata.io/zh-cn/docs/user/quickstart.html
### 注意事项
+1.使用`seata-spring-boot-starter`的时候请关闭自动代理
+```yaml
+seata:
+ enable-auto-data-source-proxy: false
+```
+2.使用 `seata-all` 请不要使用 `@EnableAutoDataSourceProxy`
-在使用 Seata 分布式事务时,请注意添加 Seata 的相关 Maven 依赖,例如:
+3.如果是 SpringBoot 项目需要引入相关 Maven 依赖,例如:
```xml
@@ -234,3 +240,7 @@ public void purchase(String userId, String commodityCode, int orderCount) {
1.7.0
```
+### 示例
+
+[mybatis-flex-spring-boot-seata-demo](https://gitee.com/mybatis-flex/mybatis-flex-samples/tree/master/mybatis-flex-spring-boot-seata-demo) : Seata 官方 demo 与 flex 结合。
+
diff --git a/docs/zh/faq.md b/docs/zh/faq.md
index 109aa36d..a2a8383b 100644
--- a/docs/zh/faq.md
+++ b/docs/zh/faq.md
@@ -1,5 +1,7 @@
# 常见问题
+[[toc]]
+
## MyBatis-Flex 没有启动或者启动出错怎么办?
正常情况下,MyBatis-Flex 在启动时,会在控制台打印如下 Banner 信息,包含版本与官方网址,如果在项目启动中没有发现 MyBatis-Flex 的 Banner 打印,那就说明 MyBatis-Flex 没有被正常加载。
@@ -21,6 +23,7 @@
就可以了,不需要再添加其他 MyBatis 依赖。
- 3、是否与 `mybatis-plus-boot-starter` 共用,使 MyBatis 被优先初始化,而导致 MyBatis-Flex 没有被加载。
- 4、是否添加了 `pagehelper-spring-boot-starter` 依赖,导致传递了 `mybatis-spring-boot-starter` 依赖。如还想继续使用 pagehelper 插件,点击 [这里](#与-pagehelper-集成出现错误) 查看解决方案。
+- 5、是否 Spring Boot 版本过低,请使用 Spring Boot 2.2 及其以上版本,点击 [这里](#springboot-项目-启动报错-java-lang-classnotfoundexception-org-springframework-transaction-transactionmanager) 获取详细信息。
## 示例中的 AccountMapper 和 "ACCOUNT" 在哪里,报错了。
@@ -62,6 +65,11 @@ in alimaven (http://maven.aliyun.com/nexus/content/groups/public/)
```
+## SpringBoot 项目,启动报错 java.lang.ClassNotFoundException: org.springframework.transaction.TransactionManager
+
+这个应该是 Spring Boot 版本的问题,`org.springframework.transaction.TransactionManager` 这个类是 Spring Framework 5.2
+新增的,对应 Spring Boot 的版本应该是 Spring Boot 2.2 及其以上版本,所以应该使用 Spring Boot 2.2 及其以上版本。
+
## SpringBoot 项目,启动报错 Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
如果当前依赖没有连接池相关依赖,则建议添加 HikariCP 依赖。
@@ -88,6 +96,18 @@ SpringBoot v3.x 添加 hikariCP 的内容如下:
> 如果使用的是 druid 数据库连接池,则需要添加数据源类型的配置 `spring.datasource.type=com.alibaba.druid.pool.DruidDataSource`。
+## SpringBoot 项目中出现 class "com.xxx" cannot be cast class "com.xxx" 的错误
+这个问题是由于 Spring 的 devtools 热加载引起的,可以在项目的 `resources/META-INF`
+目录下创建一个名为 `spring-devtools.properties` 的配置文件,配置内容如下:
+
+```properties
+restart.include.mapper=/mapper-[\\w-\\.].jar
+restart.include.pagehelper=/pagehelper-[\\w-\\.].jar
+restart.include.mybatis-flex=/mybatis-flex-[\\w-\\.]+jar
+```
+相关文档参考 Spring 的官方网站:https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using.devtools.restart.customizing-the-classload
+
+
## java.sql.SQLException: No value specified for parameter x
出现这个问题,原因是 MyBatis-Flex 未能正常启动,SQL 执行没有经过 MyBatis-Flex 导致的。其直接是因为和其他第三方增强框架整合使用了,
比如和 MyBatis-Plus、或者 PageHelper 等整合造成的。
@@ -161,13 +181,29 @@ spring:
com.github.pagehelper
pagehelper
- 版本号
+ 5.3.3
```
解决方案:https://gitee.com/mybatis-flex/mybatis-flex/issues/I71AUE
+## 代码生成器获取不到注释
+如果是 MySQL 数据库的话,可能是因为数据库版本太低,解决办法:MySQL 5.* 需要在 jdbcUrl 设置参数 `useInformationSchema=true` 才能获取到注释。
+
+例如:`jdbc:mysql://127.0.0.1:3306/mybatis-flex?characterEncoding=UTF-8&useInformationSchema=true`
+
+## 与 Nacos 集成时出错,无法正常启动 MyBatis-Flex
+
+一般请看下是缺少 Nacos 的相关 Maven,注意添加如下的 Nacos 依赖:
+
+```xml
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+ 2022.0.0.0
+
+```
## 如何自定义 MyBatis 的 Configuration?
diff --git a/docs/zh/intro/getting-started.md b/docs/zh/intro/getting-started.md
index 1af31103..64a32680 100644
--- a/docs/zh/intro/getting-started.md
+++ b/docs/zh/intro/getting-started.md
@@ -51,7 +51,7 @@ VALUES (1, '张三', 18, '2020-01-11'),
com.mybatis-flex
mybatis-flex-spring-boot-starter
- 1.5.6
+ 1.5.7
com.mysql
diff --git a/docs/zh/intro/maven.md b/docs/zh/intro/maven.md
index c49f0978..67db8972 100644
--- a/docs/zh/intro/maven.md
+++ b/docs/zh/intro/maven.md
@@ -12,12 +12,12 @@
com.mybatis-flex
mybatis-flex-core
- 1.5.6
+ 1.5.7
com.mybatis-flex
mybatis-flex-processor
- 1.5.6
+ 1.5.7
provided
```
@@ -28,12 +28,12 @@
com.mybatis-flex
mybatis-flex-spring
- 1.5.6
+ 1.5.7
com.mybatis-flex
mybatis-flex-processor
- 1.5.6
+ 1.5.7
provided
``````
@@ -44,12 +44,12 @@
com.mybatis-flex
mybatis-flex-spring-boot-starter
- 1.5.6
+ 1.5.7
com.mybatis-flex
mybatis-flex-processor
- 1.5.6
+ 1.5.7
provided
```
@@ -60,7 +60,7 @@
参考:[APT 设置-和 Lombok、Mapstruct 整合](../others/apt.md)
-> 在Kotlin中使用时,请参考[在Kotlin中使用注解处理器](../kotlin/kapt.md)
+> 在Kotlin中使用时,请参考[在Kotlin中使用注解处理器](../others/kapt.md)
```xml
@@ -72,7 +72,7 @@
com.mybatis-flex
mybatis-flex-processor
- 1.5.6
+ 1.5.7
diff --git a/docs/zh/others/apt.md b/docs/zh/others/apt.md
index 4cd26be2..a6ef512d 100644
--- a/docs/zh/others/apt.md
+++ b/docs/zh/others/apt.md
@@ -220,7 +220,7 @@ pom.xml 添加 `annotationProcessorPaths` 配置,
```
dependencies {
...
- annotationProcessor 'com.mybatis-flex:mybatis-flex-processor:1.5.6'
+ annotationProcessor 'com.mybatis-flex:mybatis-flex-processor:1.5.7'
}
```
diff --git a/docs/zh/others/codegen.md b/docs/zh/others/codegen.md
index 1b9b5237..df450465 100644
--- a/docs/zh/others/codegen.md
+++ b/docs/zh/others/codegen.md
@@ -10,7 +10,7 @@
com.mybatis-flex
mybatis-flex-codegen
- 1.5.6
+ 1.5.7
```
diff --git a/docs/zh/kotlin/kapt.md b/docs/zh/others/kapt.md
similarity index 100%
rename from docs/zh/kotlin/kapt.md
rename to docs/zh/others/kapt.md
diff --git a/mybatis-flex-annotation/pom.xml b/mybatis-flex-annotation/pom.xml
index bf8fa81f..92d91ce8 100644
--- a/mybatis-flex-annotation/pom.xml
+++ b/mybatis-flex-annotation/pom.xml
@@ -5,7 +5,7 @@
parent
com.mybatis-flex
- 1.5.6
+ 1.5.7
4.0.0
diff --git a/mybatis-flex-codegen/pom.xml b/mybatis-flex-codegen/pom.xml
index 0a260491..5a4fbb17 100644
--- a/mybatis-flex-codegen/pom.xml
+++ b/mybatis-flex-codegen/pom.xml
@@ -5,7 +5,7 @@
parent
com.mybatis-flex
- 1.5.6
+ 1.5.7
4.0.0
diff --git a/mybatis-flex-codegen/src/main/resources/templates/enjoy/serviceImpl.tpl b/mybatis-flex-codegen/src/main/resources/templates/enjoy/serviceImpl.tpl
index edcb3693..c1669d7e 100644
--- a/mybatis-flex-codegen/src/main/resources/templates/enjoy/serviceImpl.tpl
+++ b/mybatis-flex-codegen/src/main/resources/templates/enjoy/serviceImpl.tpl
@@ -87,6 +87,30 @@ public class #(table.buildServiceImplClassName()) extends #(serviceImplConfig.bu
return super.getOneAs(query, asType);
}
+ @Override
+ @Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
+ public Object getObj(QueryWrapper query) {
+ return super.getObj(query);
+ }
+
+ @Override
+ @Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
+ public R getObjAs(QueryWrapper query, Class asType) {
+ return super.getObjAs(query, asType);
+ }
+
+ @Override
+ @Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
+ public List