This commit is contained in:
farukonfly 2024-01-10 00:47:27 +08:00
commit ab5a21a450
60 changed files with 435 additions and 188 deletions

View File

@ -7,7 +7,7 @@ body:
attributes:
label: 这个 Bug 是否已经存在:
options:
- label: 我确定已经把 MyBatis-Flex 升级到最新版本 v1.7.6,并已搜索过现有的问题 (https://gitee.com/mybatis-flex/mybatis-flex/issues)
- label: 我确定已经把 MyBatis-Flex 升级到最新版本 v1.7.7,并已搜索过现有的问题 (https://gitee.com/mybatis-flex/mybatis-flex/issues)
required: true
- type: textarea
attributes:

View File

@ -13,7 +13,7 @@ body:
attributes:
label: 这个问题是否已经存在:
options:
- label: 我确定已经把 MyBatis-Flex 升级到最新版本 v1.7.6,并已搜索过现有的问题 (https://gitee.com/mybatis-flex/mybatis-flex/issues)
- label: 我确定已经把 MyBatis-Flex 升级到最新版本 v1.7.7,并已搜索过现有的问题 (https://gitee.com/mybatis-flex/mybatis-flex/issues)
required: true
- type: textarea
id: question-description

View File

@ -2,6 +2,22 @@
查看 [全部代码贡献者](/zh/intro/what-is-mybatisflex.html#贡献者)。
## v1.7.7 20240104:
- 新增:添加 spring-boot3 新模块,用于 springboot v3 下使用,感谢 @Suomm
- 新增QueryMethods 添加 NOT (column) 函数,感谢 @wittplus
- 优化:更新 Solon 下的 @ProxyComponent@Component,感谢 @citysoft
- 优化:修改 com.mybatisflex.annotation.SetListener 的注释错误,感谢 @whzzone
- 优化:修改 GBase_8s 数据库类型 sql 语句无反义处理
- 优化:升级 MyBatis 到 3.5.15 最新版本 #I8PQLC
- 修复IService.getOne 没有添加 limit 1 的问题
- 修复Db.updateEntitiesBatch 更新部分字段时报错的问题,感谢 @617054137
- 文档:更新在 Kotlin 下使用的相关文档,感谢 @kamo-sama
- 文档:优化示例代码提交语言标识,感谢 @bf109f
- 文档:更新存在一个为 is_deleted 的字段中拼写错误,感谢 @shuangtao
## v1.7.6 20231223:
- 新增Db.selectFirstAndSecondColumnsAsMap 方法:查询结果的第一列作为 key第二列作为 value感谢 @617054137
- 新增:方言添加添加权限处理统一入口 prepareAuth感谢 @bf109f

View File

@ -78,8 +78,8 @@ const {Layout} = DefaultTheme
<!--docs: https://vitepress.dev/guide/extending-default-theme#layout-slots-->
<template #doc-before>
<div style="margin-bottom: 30px">
<a href="https://aieditor.dev" target="_blank">
<img src="/assets/images/ad/doc-banner.jpg">
<a href="https://mp.weixin.qq.com/s/V34VkARgBCBKdytSlKhosg" target="_blank">
<img src="/assets/images/ad/admin-banner.jpg">
</a>
</div>
</template>

View File

@ -1,12 +1,8 @@
:root {
--vp-c-brand: #F06C33;
--vp-c-brand-light: #FFCC00;
--vp-c-brand-lighter: #FFCC99;
--vp-c-brand-dark: #FF9933;
--vp-c-brand-darker: #CC6600;
--vp-custom-block-tip-border: #FFCC99;
--vp-custom-block-tip-text: #F06C33;
--vp-c-brand-1:#F06C33;
--vp-home-hero-name-color:#F06C33;
--vp-button-brand-bg:#F06C33;
--vp-button-brand-hover-bg:#ff986b;
}
.vp-doc .custom-block p {

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

View File

@ -6,6 +6,6 @@
"docs:preview": "vitepress preview"
},
"devDependencies": {
"vitepress": "^1.0.0-beta.3 "
"vitepress": "^1.0.0-rc.32"
}
}

View File

@ -10,9 +10,9 @@ MyBatis-Flex 展示的机会。
在本站对应的位置放置您的 LOGO 及跳转链接。
| 位置 | 素材 | 宽高 | 赞助费 | 名额 |
| ---------------- | ---------------- | ------------- | ---------- |------------ |
| ---------------- | ---------------- |----------| ---------- |----|
| 全站右侧边栏 1 | 图片+链接 | 105*50px | ¥200/月 | 8 |
| 全站右侧边栏 2 | 图片+链接 | 122*50px | ¥400/月 |1 |
| 全站右侧边栏 2 | 图片+链接 | 222*50px | ¥400/月 | 1 |
您可以联系微信 `fuh99888` 就展示位的详细事宜。

View File

@ -2,6 +2,22 @@
查看 [全部代码贡献者](/zh/intro/what-is-mybatisflex.html#贡献者)。
## v1.7.7 20240104:
- 新增:添加 spring-boot3 新模块,用于 springboot v3 下使用,感谢 @Suomm
- 新增QueryMethods 添加 NOT (column) 函数,感谢 @wittplus
- 优化:更新 Solon 下的 @ProxyComponent@Component,感谢 @citysoft
- 优化:修改 com.mybatisflex.annotation.SetListener 的注释错误,感谢 @whzzone
- 优化:修改 GBase_8s 数据库类型 sql 语句无反义处理
- 优化:升级 MyBatis 到 3.5.15 最新版本 #I8PQLC
- 修复IService.getOne 没有添加 limit 1 的问题
- 修复Db.updateEntitiesBatch 更新部分字段时报错的问题,感谢 @617054137
- 文档:更新在 Kotlin 下使用的相关文档,感谢 @kamo-sama
- 文档:优化示例代码提交语言标识,感谢 @bf109f
- 文档:更新存在一个为 is_deleted 的字段中拼写错误,感谢 @shuangtao
## v1.7.6 20231223:
- 新增Db.selectFirstAndSecondColumnsAsMap 方法:查询结果的第一列作为 key第二列作为 value感谢 @617054137
- 新增:方言添加添加权限处理统一入口 prepareAuth感谢 @bf109f

View File

@ -119,7 +119,7 @@ public class AuthDialectImpl extends CommonsDialectImpl {
`QueryWrapper`的表做筛选可参考 **方式1**
在项目启动时通过 `DialectFactory` 注册 `AuthDialectImpl`以spring boot项目为例
```
```java
@Configuration
public class MybatisFlexConfig implements MyBatisFlexCustomizer {

View File

@ -10,7 +10,7 @@
## MyBatis-Flex 逻辑删除示例
假设在 tb_account 表中,存在一个为 is_deleted 的字段,用来标识该数据的逻辑删除,那么 tb_account 表
假设在 tb_account 表中,存在一个为 is_delete 的字段,用来标识该数据的逻辑删除,那么 tb_account 表
对应的 "Account.java" 实体类应该配置如下:
```java

View File

@ -57,12 +57,11 @@ VALUES (1, '张三', 18, '2020-01-11'),
需要添加的 Maven 主要依赖示例:
```xml
<dependencies>
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
@ -82,6 +81,35 @@ VALUES (1, '张三', 18, '2020-01-11'),
</dependencies>
```
**注意** 如果您当前使用的是 SpringBoot v3.x 版本,需要把依赖 `mybatis-flex-spring-boot-starter` 修改为:`mybatis-flex-spring-boot3-starter`,
如下代码所示:
```xml 4
<dependencies>
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring-boot3-starter</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<!-- for test only -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
```
**第 3 步:对 Spring Boot 项目进行配置**
在 application.yml 中配置数据源:

View File

@ -10,7 +10,7 @@
```kotlin
dependencies {
implementation("com.mybatis-flex:mybatis-flex-core:1.7.6")
implementation("com.mybatis-flex:mybatis-flex-core:1.7.7")
}
```
@ -18,7 +18,7 @@ dependencies {
```groovy
dependencies {
implementation 'com.mybatis-flex:mybatis-flex-core:1.7.6'
implementation 'com.mybatis-flex:mybatis-flex-core:1.7.7'
}
```
@ -28,7 +28,7 @@ dependencies {
```kotlin
dependencies {
implementation("com.mybatis-flex:mybatis-flex-spring:1.7.6")
implementation("com.mybatis-flex:mybatis-flex-spring:1.7.7")
}
```
@ -36,7 +36,7 @@ dependencies {
```groovy
dependencies {
implementation 'com.mybatis-flex:mybatis-flex-spring:1.7.6'
implementation 'com.mybatis-flex:mybatis-flex-spring:1.7.7'
}
```
@ -46,7 +46,7 @@ dependencies {
```kotlin
dependencies {
implementation("com.mybatis-flex:mybatis-flex-spring-boot-starter:1.7.6")
implementation("com.mybatis-flex:mybatis-flex-spring-boot-starter:1.7.7")
}
```
@ -54,7 +54,7 @@ dependencies {
```groovy
dependencies {
implementation 'com.mybatis-flex:mybatis-flex-spring-boot-starter:1.7.6'
implementation 'com.mybatis-flex:mybatis-flex-spring-boot-starter:1.7.7'
}
```
@ -70,7 +70,7 @@ dependencies {
```kotlin
dependencies {
annotationProcessor("com.mybatis-flex:mybatis-flex-processor:1.7.6")
annotationProcessor("com.mybatis-flex:mybatis-flex-processor:1.7.7")
}
```
@ -78,6 +78,6 @@ dependencies {
```groovy
dependencies {
annotationProcessor 'com.mybatis-flex:mybatis-flex-processor:1.7.6'
annotationProcessor 'com.mybatis-flex:mybatis-flex-processor:1.7.7'
}
```

View File

@ -12,12 +12,12 @@
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-core</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-processor</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
<scope>provided</scope>
</dependency>
```
@ -28,33 +28,49 @@
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-processor</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
<scope>provided</scope>
</dependency>
``````
3、用到了 Spring Boot 的场景
3、用到了 SpringBoot v2.x 的场景
```xml
```xml 3
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-processor</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
<scope>provided</scope>
</dependency>
```
4、配置 annotationProcessor
4、用到了 SpringBoot v3.x 的场景
```xml 3
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring-boot3-starter</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-processor</artifactId>
<version>1.7.7</version>
<scope>provided</scope>
</dependency>
```
5、配置 annotationProcessor
`mybatis-flex-processor`提供APT服务可以配置到annotationProcessorPaths配置后无需在依赖中声明`mybatis-flex-processor`依赖。
@ -72,14 +88,14 @@
<path>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-processor</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
```
5、配置依赖管理
6、配置依赖管理
MyBatis-Flex 提供了 `mybatis-flex-dependencies` 模块进行依赖管理,只需要在 `<dependencyManagement>` 标签下进行配置就可以了。

View File

@ -1,23 +1,28 @@
| | | | | |
|-----|-----|-----|-----|-----|
|![](https://foruda.gitee.com/avatar/1676898191051702081/61279_fuhai_1578915942.png!avatar60)Michael Yang|![](https://foruda.gitee.com/avatar/1698661375322784129/7984572_suomm_1698661375.png!avatar60)王帅|![](https://api.dicebear.com/7.x/initials/svg?seed=丌冰)丌冰|![](https://foruda.gitee.com/avatar/1691636027051962328/11233353_kamo-sama_1691636027.png!avatar60)卡莫sama|![](https://foruda.gitee.com/avatar/1691044597656855579/7563907_lifejwang11_1691044597.png!avatar60)life|
|![](https://api.dicebear.com/7.x/initials/svg?seed=snyk-bot)snyk-bot|![](https://api.dicebear.com/7.x/initials/svg?seed=lhzsdnu)lhzsdnu|![](https://foruda.gitee.com/avatar/1683858335519306352/15535_noear_admin_1683858335.png!avatar60)西东|![](https://api.dicebear.com/7.x/initials/svg?seed=Font_C)Font_C|![](https://api.dicebear.com/7.x/initials/svg?seed=pengpeng)pengpeng|
|![](https://api.dicebear.com/7.x/initials/svg?seed=庄佳彬)庄佳彬|![](https://api.dicebear.com/7.x/initials/svg?seed=Ice-samll)Ice-samll|![](https://api.dicebear.com/7.x/initials/svg?seed=guanmengyuan)guanmengyuan|![](https://foruda.gitee.com/avatar/1697612161781835336/7870258_wchopper_1697612161.png!avatar60)王超|![](https://api.dicebear.com/7.x/initials/svg?seed=笨小孩)笨小孩|
|![](https://api.dicebear.com/7.x/initials/svg?seed=chenjh3)chenjh3|![](https://api.dicebear.com/7.x/initials/svg?seed=CloudPlayer)CloudPlayer|![](https://api.dicebear.com/7.x/initials/svg?seed=Jerry)Jerry|![](https://api.dicebear.com/7.x/initials/svg?seed=snow)snow|![](https://api.dicebear.com/7.x/initials/svg?seed=草语)草语|
|![](https://foruda.gitee.com/avatar/1694759381586775676/568596_qq925966998_1694759381.png!avatar60)李楠|![](https://api.dicebear.com/7.x/initials/svg?seed=菜鸟3853)菜鸟3853|![](https://api.dicebear.com/7.x/initials/svg?seed=Jerry_Zheng)Jerry_Zheng|![](https://api.dicebear.com/7.x/initials/svg?seed=tangxin)tangxin|![](https://api.dicebear.com/7.x/initials/svg?seed=wujl)wujl|
|![](https://foruda.gitee.com/avatar/1676895504036051867/8807_piggsoft_1578914592.jpg!avatar60)piggsoft|![](https://foruda.gitee.com/avatar/1674286432514482953/4807650_fandai_fandaidzsw_1674286432.png!avatar60)赤兮丷|![](https://api.dicebear.com/7.x/initials/svg?seed=黄沐鸿)黄沐鸿|![](https://api.dicebear.com/7.x/initials/svg?seed=loong0306)loong0306|![](https://api.dicebear.com/7.x/initials/svg?seed=沈君锋)沈君锋|
|![](https://foruda.gitee.com/avatar/1691034002435340221/1920167_qimincow_1691034002.png!avatar60)英雄路|![](https://api.dicebear.com/7.x/initials/svg?seed=natsufumij)natsufumij|![](https://api.dicebear.com/7.x/initials/svg?seed=aqnghu)aqnghu|![](https://api.dicebear.com/7.x/initials/svg?seed=BQ60ziOxlFI0R0)BQ60ziOxlFI0R0|![](https://api.dicebear.com/7.x/initials/svg?seed=tan90)tan90|
|![](https://api.dicebear.com/7.x/initials/svg?seed=张继续)张继续|![](https://api.dicebear.com/7.x/initials/svg?seed=font-C)font-C|![](https://foruda.gitee.com/avatar/1677053740056224121/5462387_i_tell_you_1618064317.png!avatar60)liibang|![](https://api.dicebear.com/7.x/initials/svg?seed=cainiao3853)cainiao3853|![](https://api.dicebear.com/7.x/initials/svg?seed=barql)barql|
|![](https://api.dicebear.com/7.x/initials/svg?seed=yangs)yangs|![](https://foruda.gitee.com/avatar/1677086127012961929/7598208_robot-l_1590219712.png!avatar60)Robot.L|![](https://foruda.gitee.com/avatar/1695378372753910643/2130728_lemonbx_1695378372.png!avatar60)落羽er|![](https://api.dicebear.com/7.x/initials/svg?seed=qixy)qixy|![](https://api.dicebear.com/7.x/initials/svg?seed=yuanbaolong)yuanbaolong|
|![](https://foruda.gitee.com/avatar/1678377314939642686/1604115_handy-git_1678377314.png!avatar60)handy|![](https://api.dicebear.com/7.x/initials/svg?seed=zhijieqing)zhijieqing|![](https://foruda.gitee.com/avatar/1674121508509280199/9288653_saoforestt_1674121508.png!avatar60)Saoforest|![](https://foruda.gitee.com/avatar/1677237805724097193/11485875_bygkn_1660893367.png!avatar60)bygkn|![](https://api.dicebear.com/7.x/initials/svg?seed=XiaoLin)XiaoLin|
|![](https://api.dicebear.com/7.x/initials/svg?seed=zhongyong)zhongyong|![](https://foruda.gitee.com/avatar/1676978624694631546/1600987_youthdream_1592959590.png!avatar60)锟斤拷|![](https://api.dicebear.com/7.x/initials/svg?seed=Watcher.Wang)Watcher.Wang|![](https://foruda.gitee.com/avatar/1677111694079591934/8088436_yang-zzu_1604969134.png!avatar60)yang_zzu|![](https://foruda.gitee.com/avatar/1676895416224286260/8331_chaosforever_1578914555.png!avatar60)锁力|
|![](https://api.dicebear.com/7.x/initials/svg?seed=shaoerkuai)shaoerkuai|![](https://foruda.gitee.com/avatar/1679885039814030308/5151444_yangbuyi_1679885039.png!avatar60)阿志同学|![](https://api.dicebear.com/7.x/initials/svg?seed=chenjian835)chenjian835|![](https://foruda.gitee.com/avatar/1676896586274105369/20327_cnscoo_1578915320.jpg!avatar60)Haru|![](https://foruda.gitee.com/avatar/1676896562075035262/20021_duxlei_1578915302.png!avatar60)duxlei|
|![](https://foruda.gitee.com/avatar/1676905453682965545/327218_gm173119755_1648555045.png!avatar60)豌豆粉|![](https://api.dicebear.com/7.x/initials/svg?seed=matthew)matthew|![](https://api.dicebear.com/7.x/initials/svg?seed=凌尘)凌尘|![](https://api.dicebear.com/7.x/initials/svg?seed=luy)luy|![](https://api.dicebear.com/7.x/initials/svg?seed=gongzhongqiang)gongzhongqiang|
|![](https://api.dicebear.com/7.x/initials/svg?seed=Alex)Alex|![](https://api.dicebear.com/7.x/initials/svg?seed=EafonYoung)EafonYoung|![](https://foruda.gitee.com/avatar/1677170868635098448/9319924_pioneer-sun_1624354686.png!avatar60)Pioneer-Sun|![](https://foruda.gitee.com/avatar/1677166292370951564/9173563_q-alex_1627784508.png!avatar60)Q_Alex|![](https://foruda.gitee.com/avatar/1677052070334379576/5421002_wlf213_1612139033.png!avatar60)wlf|
|![](https://foruda.gitee.com/avatar/1676898238064465096/61541_whitedolphin_1578915956.png!avatar60)CrazyAirhead|![](https://api.dicebear.com/7.x/initials/svg?seed=winnerself)winnerself|![](https://foruda.gitee.com/avatar/1677182504887358627/9655223_animal553_1631088642.png!avatar60)她出去赚钱了|![](https://foruda.gitee.com/avatar/1694921912224475489/8702036_dataprince_1694921912.png!avatar60)数据小王子|![](https://api.dicebear.com/7.x/initials/svg?seed=XiaoLin)XiaoLin|
|![](https://api.dicebear.com/7.x/initials/svg?seed=Freeman Liu)Freeman Liu|![](https://api.dicebear.com/7.x/initials/svg?seed=大周)大周|![](https://api.dicebear.com/7.x/initials/svg?seed=欢乐码农)欢乐码农|![](https://api.dicebear.com/7.x/initials/svg?seed=2han9wen71an)2han9wen71an|![](https://api.dicebear.com/7.x/initials/svg?seed=Shark)Shark|
|![](https://api.dicebear.com/7.x/initials/svg?seed=庄佳彬)庄佳彬|![](https://api.dicebear.com/7.x/initials/svg?seed=hans)hans|![](https://foruda.gitee.com/avatar/1677173250729036908/9369933_hunnyovo_1650792499.png!avatar60)HunnyOvO|![](https://foruda.gitee.com/avatar/1696779720632916032/13315404_guan-meng-yuan_1696779720.png!avatar60)关梦园|![](https://api.dicebear.com/7.x/initials/svg?seed=lcxw)lcxw|
|![](https://api.dicebear.com/7.x/initials/svg?seed=dgmico)dgmico|![](https://foruda.gitee.com/avatar/1677162544015233775/9094323_lymph_java_1624796992.png!avatar60)Ikko Eltociear Ashimine|![](https://api.dicebear.com/7.x/initials/svg?seed=wanggaoquan)wanggaoquan|![](https://foruda.gitee.com/avatar/1689673717825068611/9856206_aohanaohan_1689673717.png!avatar60)Aohan-Zhang|![](https://foruda.gitee.com/avatar/1691737477130376308/1673084_wang_yong_ji_1691737477.png!avatar60)老吉丶|
|![](https://foruda.gitee.com/avatar/1684129987239221781/1731138_toycat93_1684129987.png!avatar60)玩具猫|![](https://api.dicebear.com/7.x/initials/svg?seed=meng.liu3)meng.liu3|![](https://api.dicebear.com/7.x/initials/svg?seed=yaochen4)yaochen4|![](https://foruda.gitee.com/avatar/1676959401839738321/1269497_zhy_balck_1578947791.png!avatar60)zhy_black|![](https://foruda.gitee.com/avatar/1676974596171836113/1532463_1395961821_1578953848.png!avatar60)ζั͡ ั͡ ั͡ ั͡Wm|
|![](https://foruda.gitee.com/avatar/1676894749123859490/2132_hopper_1578914095.jpg!avatar60)陈国正|![](https://foruda.gitee.com/avatar/1691805683099463215/8904907_zhuhjay_1691805683.png!avatar60)ZhuHJay|![](https://foruda.gitee.com/avatar/1677071665480088881/6561865_zoufang162_1585144118.png!avatar60)zoufang162|![](https://api.dicebear.com/7.x/initials/svg?seed=乌鸦笑猪黑)乌鸦笑猪黑|![](https://api.dicebear.com/7.x/initials/svg?seed=wnp)wnp|
|![](https://foruda.gitee.com/avatar/1676898191051702081/61279_fuhai_1578915942.png!avatar30)Michael Yang|![](https://foruda.gitee.com/avatar/1698661375322784129/7984572_suomm_1698661375.png!avatar30)王帅|![](https://foruda.gitee.com/avatar/1691636027051962328/11233353_kamo-sama_1691636027.png!avatar30)卡莫sama|丌冰|![](https://foruda.gitee.com/avatar/1691044597656855579/7563907_lifejwang11_1691044597.png!avatar30)life|
|snyk-bot|lhzsdnu|![](https://foruda.gitee.com/avatar/1683858335519306352/15535_noear_admin_1683858335.png!avatar30)西东|tangxin|Font_C|
|pengpeng|庄佳彬|Ice-samll|guanmengyuan|![](https://foruda.gitee.com/avatar/1697612161781835336/7870258_wchopper_1697612161.png!avatar30)王超|
|笨小孩|bf109f|chenjh3|CloudPlayer|Jerry|
|snow|草语|farukonfly|![](https://foruda.gitee.com/avatar/1694759381586775676/568596_qq925966998_1694759381.png!avatar30)李楠|菜鸟3853|
|mofan|Jerry_Zheng|wujl|Martin7-1|![](https://foruda.gitee.com/avatar/1676895504036051867/8807_piggsoft_1578914592.jpg!avatar30)piggsoft|
|![](https://foruda.gitee.com/avatar/1674286432514482953/4807650_fandai_fandaidzsw_1674286432.png!avatar30)赤兮丷|黄沐鸿|loong0306|沈君锋|![](https://foruda.gitee.com/avatar/1691034002435340221/1920167_qimincow_1691034002.png!avatar30)英雄路|
|natsufumij|BQ60ziOxlFI0R0|tan90|aqnghu|张继续|
|font-C|![](https://foruda.gitee.com/avatar/1677053740056224121/5462387_i_tell_you_1618064317.png!avatar30)liibang|cainiao3853|![](https://foruda.gitee.com/avatar/1702438316292746960/8789215_barql_1702438316.png!avatar30)barql|yangs|
|lcxw|![](https://foruda.gitee.com/avatar/1677086127012961929/7598208_robot-l_1590219712.png!avatar30)Robot.L|![](https://foruda.gitee.com/avatar/1695378372753910643/2130728_lemonbx_1695378372.png!avatar30)落羽er|Faputa|qixy|
|yuanbaolong|zhijieqing|![](https://foruda.gitee.com/avatar/1678377314939642686/1604115_handy-git_1678377314.png!avatar30)handy|![](https://foruda.gitee.com/avatar/1677237805724097193/11485875_bygkn_1660893367.png!avatar30)bygkn|![](https://foruda.gitee.com/avatar/1674121508509280199/9288653_saoforestt_1674121508.png!avatar30)Saoforest|
|![](https://foruda.gitee.com/avatar/1676906219947351575/342237_tangzc_1629796763.png!avatar30)唐振超|Watcher.Wang|![](https://foruda.gitee.com/avatar/1676978624694631546/1600987_youthdream_1592959590.png!avatar30)锟斤拷|zhongyong|XiaoLin|
|![](https://foruda.gitee.com/avatar/1677111694079591934/8088436_yang-zzu_1604969134.png!avatar30)yang_zzu|![](https://foruda.gitee.com/avatar/1676895416224286260/8331_chaosforever_1578914555.png!avatar30)锁力|shaoerkuai|meichenhui|![](https://foruda.gitee.com/avatar/1679885039814030308/5151444_yangbuyi_1679885039.png!avatar30)阿志同学|
|chenjian835|![](https://foruda.gitee.com/avatar/1676896586274105369/20327_cnscoo_1578915320.jpg!avatar30)Haru|![](https://foruda.gitee.com/avatar/1676896562075035262/20021_duxlei_1578915302.png!avatar30)duxlei|![](https://foruda.gitee.com/avatar/1676905453682965545/327218_gm173119755_1648555045.png!avatar30)豌豆粉|涛声依旧|
|matthew|gongzhongqiang|luy|凌尘|Alex|
|EafonYoung|![](https://foruda.gitee.com/avatar/1677170868635098448/9319924_pioneer-sun_1624354686.png!avatar30)Pioneer-Sun|![](https://foruda.gitee.com/avatar/1677166292370951564/9173563_q-alex_1627784508.png!avatar30)Q_Alex|![](https://foruda.gitee.com/avatar/1677052070334379576/5421002_wlf213_1612139033.png!avatar30)wlf|1332987|
|Lionel|winnerself|![](https://foruda.gitee.com/avatar/1676898238064465096/61541_whitedolphin_1578915956.png!avatar30)CrazyAirhead|![](https://foruda.gitee.com/avatar/1677182504887358627/9655223_animal553_1631088642.png!avatar30)她出去赚钱了|![](https://foruda.gitee.com/avatar/1694921912224475489/8702036_dataprince_1694921912.png!avatar30)数据小王子|
|XiaoLin|丿风轻灬云淡|![](https://foruda.gitee.com/avatar/1703832348210958955/7966959_zhang-bo-bo_1703832348.png!avatar30)张博|Freeman Liu|大周|
|欢乐码农|2han9wen71an|shark771|庄佳彬|_FLOW__|
|![](https://foruda.gitee.com/avatar/1677062003782215413/5643954_wei_hua_zhou_1653878946.png!avatar30)weihuazhou|hans|![](https://foruda.gitee.com/avatar/1677162544015233775/9094323_lymph_java_1624796992.png!avatar30)Ikko Eltociear Ashimine|guanmengyuan|dgmico|
|![](https://foruda.gitee.com/avatar/1677173250729036908/9369933_hunnyovo_1650792499.png!avatar30)HunnyOvO|wanggaoquan|![](https://foruda.gitee.com/avatar/1689673717825068611/9856206_aohanaohan_1689673717.png!avatar30)Aohan-Zhang|![](https://foruda.gitee.com/avatar/1691737477130376308/1673084_wang_yong_ji_1691737477.png!avatar30)老吉丶|![](https://foruda.gitee.com/avatar/1684129987239221781/1731138_toycat93_1684129987.png!avatar30)玩具猫|
|meng.liu3|yaochen4|![](https://foruda.gitee.com/avatar/1676959401839738321/1269497_zhy_balck_1578947791.png!avatar30)zhy_black|![](https://foruda.gitee.com/avatar/1676974596171836113/1532463_1395961821_1578953848.png!avatar30)ζั͡ ั͡ ั͡ ั͡Wm|![](https://foruda.gitee.com/avatar/1676894749123859490/2132_hopper_1578914095.jpg!avatar30)陈国正|
|![](https://foruda.gitee.com/avatar/1691805683099463215/8904907_zhuhjay_1691805683.png!avatar30)ZhuHJay|![](https://foruda.gitee.com/avatar/1677071665480088881/6561865_zoufang162_1585144118.png!avatar30)zoufang162|乌鸦笑猪黑|wnp|![](https://foruda.gitee.com/avatar/1676901646505077446/106613_myron_1578917779.png!avatar30)MyronLi|
|norkts|拓宇在思考|张春根|![](https://foruda.gitee.com/avatar/1699925437720003320/5656388_wittplus_1699925437.png!avatar30)witt|![](https://foruda.gitee.com/avatar/1676983827162237415/1697554_xinjump_1654653784.png!avatar30)xinjump|
|![](https://foruda.gitee.com/avatar/1693449200752633970/11209107_jl_0417_1693449200.png!avatar30)疾浪|sppan|![](https://foruda.gitee.com/avatar/1662084101462823713/2079235_djxchi_1662084101.png!avatar30)时间淡忘一切|

View File

@ -19,34 +19,37 @@
- 快速构建启动通过DSL重载运算符快速配置 MybatisFlexBootstrap 实例并启动:
```kotlin
buildBootstrap {
runFlex {
// 配置数据源 相当于 setDataSource(dataSource)
+dataSource
// 配置Mapper 相当于 addMapper(AccountMapper::class.java)
+AccountMapper::class
// 配置日志输出 相当于 setLogImpl(StdOutImpl::class.java)
logImpl = StdOutImpl::class
}.start()
}
```
- 快速查询数据通过DSL泛型快速编写查询语句并查询: (快速查询提供三个函数all, filter 和 query )
>- `all<实体类>()` 查泛型对应的表的所有数据
>- `filter<实体类>(vararg KProperty<*>, ()->QueryCondition)` 按条件查泛型对应的表的数据
>- `query<实体类>(QueryScope.()->Unit)` 较复杂查泛型对应的表的数据 (如: 分组,排序等)
>- `paginateWith(pageNumber: Number, pageSize: Number, totalRow: Number? = null, queryConditionGet: () -> QueryCondition): Page<实体类>`
`paginate(pageNumber: Number, pageSize: Number, totalRow: Number? = null, init: QueryScope.() -> Unit): Page<实体类>` 使用分页的条件查询与较复杂查询
- 简明地构建查询:通过中缀表达式➕扩展方法能更加简单明了的构建条件:
* **【对比原生】**
* **原生**
```kotlin
val queryWrapper = QueryWrapper.create()
.select(Account::id.column(), Account::userName.column())
.where(Account::age.column().isNotNull()).and(Account::age.column().ge(17))
.orderBy(Account::id.column().desc())
.select(QueryColumn("id"), QueryColumn("user_name"))
.where(QueryColumn("age").isNotNull()).and(QueryColumn("age").ge(17))
.orderBy(QueryColumn("id").desc())
mapper<AccountMapper>().selectListByQuery(queryWrapper)
```
* **扩展后**
```kotlin
query<Account> {
// 无需注册Mapper与APT/KSP即可查询操作
val accountList: List<Account> = query {
select(Account::id, Account::userName)
where(Account::age.isNotNull) and { Account::age ge 17 } orderBy -Account::id
}
@ -80,7 +83,6 @@
WHERE (`id` = 1 AND `user_name` = '张三' AND `age` = 18)
OR (`id` = 2 AND `user_name` = '李四' AND `age` = 19)
```
- 摆脱APT: 使用扩展方法摆脱对 APT(注解处理器) 的使用,直接使用属性引用让代码更加灵活优雅:
> 使用APT: `ACCOUNT.ID eq 1` ,使用属性引用: `Account::id eq 1`
>

View File

@ -220,7 +220,7 @@ pom.xml 添加 `annotationProcessorPaths` 配置,
```
dependencies {
...
annotationProcessor 'com.mybatis-flex:mybatis-flex-processor:1.7.6'
annotationProcessor 'com.mybatis-flex:mybatis-flex-processor:1.7.7'
}
```

View File

@ -10,7 +10,7 @@
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-codegen</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
</dependency>
```

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -26,7 +26,7 @@ public interface SetListener extends Listener {
* @param entity 实体类
* @param property 属性名
* @param value 属性值
* @return 实体类
* @return 属性值
*/
Object onSet(Object entity, String property, Object value);

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -23,7 +23,7 @@
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-core</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
<exclusions>
<exclusion>
<groupId>com.mybatis-flex</groupId>

View File

@ -4,7 +4,7 @@ import com.mybatisflex.solon.service.impl.ServiceImpl;
import #(packageConfig.entityPackage).#(table.buildEntityClassName());
import #(packageConfig.mapperPackage).#(table.buildMapperClassName());
import #(packageConfig.servicePackage).#(table.buildServiceClassName());
import org.noear.solon.annotation.ProxyComponent;
import org.noear.solon.annotation.Component;
/**
* #(table.getComment()) 服务层实现。
@ -12,7 +12,7 @@ import org.noear.solon.annotation.ProxyComponent;
* @author #(javadocConfig.getAuthor())
* @since #(javadocConfig.getSince())
*/
@ProxyComponent
@Component
public class #(table.buildServiceImplClassName()) extends ServiceImpl<#(table.buildMapperClassName()), #(table.buildEntityClassName())> implements #(table.buildServiceClassName()) {
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -101,7 +101,7 @@
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-annotation</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
<scope>compile</scope>
</dependency>

View File

@ -27,7 +27,7 @@ public class FlexConsts {
}
public static final String NAME = "MyBatis-Flex";
public static final String VERSION = "1.7.6";
public static final String VERSION = "1.7.7";
public static final String SQL = "$$sql";

View File

@ -127,6 +127,7 @@ public class DialectFactory {
case DORIS:
return new CommonsDialectImpl(KeywordWrap.BACK_QUOTE, LimitOffsetProcessor.MYSQL);
case CLICK_HOUSE:
case GBASE_8S:
return new CommonsDialectImpl(KeywordWrap.NONE, LimitOffsetProcessor.MYSQL);
case DM:
return new DmDialect();

View File

@ -479,7 +479,7 @@ public class FlexDefaultResultSetHandler extends DefaultResultSetHandler {
private boolean applyPropertyMappings(ResultSetWrapper rsw, ResultMap resultMap, MetaObject metaObject,
ResultLoaderMap lazyLoader, String columnPrefix) throws SQLException {
final List<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
final Collection<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
boolean foundValues = false;
final List<ResultMapping> propertyMappings = resultMap.getPropertyResultMappings();
for (ResultMapping propertyMapping : propertyMappings) {
@ -1178,7 +1178,7 @@ public class FlexDefaultResultSetHandler extends DefaultResultSetHandler {
if (resultMapping.isSimple()) {
final String column = prependPrefix(resultMapping.getColumn(), columnPrefix);
final TypeHandler<?> th = resultMapping.getTypeHandler();
List<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
Collection<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
// Issue #114
if (column != null && mappedColumnNames.contains(column.toUpperCase(Locale.ENGLISH))) {
final Object value = th.getResult(rsw.getResultSet(), column);

View File

@ -30,6 +30,7 @@ import org.apache.ibatis.type.TypeHandler;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@ -84,7 +85,7 @@ public class FlexResultSetHandler extends FlexDefaultResultSetHandler {
String columnName = prependPrefix(mapping.getColumn(), columnPrefix);
TypeHandler<?> typeHandler = mapping.getTypeHandler();
List<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
Collection<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
if (columnName != null && mappedColumnNames.contains(columnName.toUpperCase(Locale.ENGLISH))) {
return typeHandler.getResult(rsw.getResultSet(), columnName);
}

View File

@ -247,8 +247,8 @@ public class RowSqlProvider {
FlexAssert.notNull(entity, "entity can not be null");
// Mapper 是通用 Mapper 无法通过 ProviderContext 获取直接使用 TableInfoFactory
TableInfo tableInfo = TableInfoFactory.ofEntityClass(ClassUtil.getUsefulClass(entity.getClass()));
TableInfo tableInfo = TableInfoFactory.ofEntityClass(ClassUtil.getUsefulClass(entity.getClass()));
// 执行 onUpdate 监听器
tableInfo.invokeOnUpdateListener(entity);

View File

@ -22,6 +22,7 @@ import com.mybatisflex.core.util.LambdaGetter;
import com.mybatisflex.core.util.LambdaUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.mybatisflex.core.constant.FuncName.*;
@ -2346,6 +2347,12 @@ public class QueryMethods {
return new DistinctQueryColumn(columns);
}
@SafeVarargs
public static <T> DistinctQueryColumn distinct(LambdaGetter<T>... columns) {
return new DistinctQueryColumn(Arrays.stream(columns)
.map(LambdaUtil::getQueryColumn).toArray(QueryColumn[]::new));
}
// === CASE THEN ELSE ===
/**
@ -2564,6 +2571,13 @@ public class QueryMethods {
return new OperatorQueryCondition("NOT ", childCondition);
}
/**
* {@code NOT (column)} {@code NOT column}
*/
public static <N> QueryColumn not(LambdaGetter<N> column) {
return new FunctionQueryColumn("NOT", LambdaUtil.getQueryColumn(column));
}
/**
* 空条件
*/

View File

@ -376,7 +376,7 @@ public interface IService<T> {
* @return 查询结果数据
*/
default T getOne(QueryCondition condition) {
return getOne(query().where(condition));
return getOne(query().where(condition).limit(1));
}
/**

View File

@ -149,8 +149,10 @@ public class ColumnInfo {
if (configuration == null) {
configuration = FlexGlobalConfig.getDefaultConfig().getConfiguration();
}
if (configuration != null) {
buildTypeHandler = configuration.getTypeHandlerRegistry().getTypeHandler(propertyType);
}
}
return buildTypeHandler;
}

View File

@ -70,14 +70,15 @@ public class ClassUtil {
}
public static <T> Class<T> getUsefulClass(Class<T> clazz) {
if (ProxyObject.class.isAssignableFrom(clazz)) {
return (Class<T>) clazz.getSuperclass();
}
if (isProxy(clazz)) {
return getJdkProxySuperClass(clazz);
}
// if (ProxyObject.class.isAssignableFrom(clazz)){
// return (Class<T>) clazz.getSuperclass();
// }
//ControllerTest$ServiceTest$$EnhancerByGuice$$40471411#hello -------> Guice
//com.demo.blog.Blog$$EnhancerByCGLIB$$69a17158 ----> CGLIB
//io.jboot.test.app.TestAppListener_$$_jvstb9f_0 ------> javassist

View File

@ -62,10 +62,6 @@ public class FieldWrapper {
&& Modifier.isPublic(method.getModifiers())
&& method.getName().equals(setterName));
if (setter == null) {
throw new IllegalStateException("Can not find method \"set" + StringUtil.firstCharToUpperCase(fieldName) + "\" in class: " + clazz);
}
fieldWrapper = new FieldWrapper();
fieldWrapper.field = findField;
fieldWrapper.fieldType = findField.getType();
@ -120,6 +116,9 @@ public class FieldWrapper {
public void set(Object value, Object to) {
try {
if (setterMethod == null) {
throw new IllegalStateException("Can not find method \"set" + StringUtil.firstCharToUpperCase(field.getName()) + "\" in class: " + to.getClass());
}
setterMethod.invoke(to, value);
} catch (Exception e) {
throw new RuntimeException(e);
@ -128,6 +127,9 @@ public class FieldWrapper {
public Object get(Object target) {
try {
if (getterMethod == null) {
throw new IllegalStateException("Can not find method \"get" + StringUtil.firstCharToUpperCase(field.getName()) + ", is" + StringUtil.firstCharToUpperCase(field.getName()) + "\" in class: " + target.getClass());
}
return getterMethod.invoke(target);
} catch (Exception e) {
throw new RuntimeException(e);

View File

@ -6,7 +6,7 @@
<parent>
<groupId>com.mybatis-flex</groupId>
<artifactId>parent</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<artifactId>mybatis-flex-dependencies</artifactId>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -22,7 +22,7 @@
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-annotation</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -23,7 +23,7 @@
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
</dependency>
<dependency>
@ -104,7 +104,7 @@
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-core</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
</dependency>
</dependencies>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mybatis-flex</groupId>
<artifactId>parent</artifactId>
<version>1.7.7</version>
</parent>
<artifactId>mybatis-flex-spring-boot3-starter</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-spring-boot-starter</artifactId>
<version>1.7.7</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>3.0.3</version>
</dependency>
</dependencies>
</project>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -22,7 +22,7 @@
<dependency>
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-core</artifactId>
<version>1.7.6</version>
<version>1.7.7</version>
</dependency>
<dependency>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>mybatis-flex-test</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -30,6 +30,7 @@ public class ContributorsDocGen {
List<String> urls = Arrays.asList(
"https://gitee.com/mybatis-flex/mybatis-flex/contributors?ref=main"
, "https://gitee.com/mybatis-flex/mybatis-flex/contributors?page=2&ref=main"
, "https://gitee.com/mybatis-flex/mybatis-flex/contributors?page=3&ref=main"
);
StringBuilder markdown = new StringBuilder();
markdown.append("| | | | | |\n" +
@ -73,12 +74,16 @@ public class ContributorsDocGen {
if (userName.contains("@")) {
userName = userName.substring(0, userName.indexOf("@"));
}
if (StringUtil.isBlank(src)) {
src = "https://api.dicebear.com/7.x/initials/svg?seed=" + userName;
}
// if (StringUtil.isBlank(src)) {
// src = "https://api.dicebear.com/7.x/initials/svg?seed=" + userName;
// }
markdown.append("|");
if (StringUtil.isNotBlank(src)) {
markdown.append("![](" + src + ")");
}
markdown.append(userName);
startIndex++;

View File

@ -82,10 +82,12 @@ public class DbTest {
Map map2 = Db.selectFirstAndSecondColumnsAsMap("select * from tb_account");
System.out.println(map);
System.out.println(map2);
assert map.equals(map2);
}
@Test
public void test03() {
try {
Account account = UpdateEntity.of(Account.class, 1);
account.setAge(1);
List<Account> accounts = new ArrayList<>();
@ -95,6 +97,13 @@ public class DbTest {
UpdateWrapper updateWrapper = UpdateWrapper.of(account2);
updateWrapper.setRaw("age", "age+1");
accounts.add(account2);
Account account3 = new Account();
account3.setId(3L);
account3.setAge(4);
accounts.add(account3);
Db.updateEntitiesBatch(accounts);
}catch (Exception e){
assert false;
}
}
}

View File

@ -4,7 +4,7 @@
<parent>
<artifactId>mybatis-flex-test</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>mybatis-flex-test</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -83,6 +83,24 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,33 @@
package com.mybatisflex.test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.MySQLContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;
import java.util.Collections;
public class TestInfrastructure {
static final String FLEX_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("flex_test.sql").getPath();
static final String FIELD_MAPPING_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("field_mapping_test.sql").getPath();
static final String PATIENT_DATA_SPLIT_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("patient_data_split_test.sql").getPath();
static final String DOCKER_INITDB_PATH = "/docker-entrypoint-initdb.d/";
static GenericContainer<?> mysql = new MySQLContainer<>(DockerImageName.parse("mysql:8.2.0"))
.waitingFor(Wait.forLogMessage(".*ready for connections.*\\n", 1))
.withFileSystemBind(FLEX_TEST_DDL, DOCKER_INITDB_PATH + "flex_test.sql", BindMode.READ_ONLY)
.withFileSystemBind(FIELD_MAPPING_TEST_DDL, DOCKER_INITDB_PATH + "field_mapping_test.sql", BindMode.READ_ONLY)
.withFileSystemBind(PATIENT_DATA_SPLIT_TEST_DDL, DOCKER_INITDB_PATH + "patient_data_split_test.sql", BindMode.READ_ONLY)
.withDatabaseName("flex_test")
.withReuse(true)
.withPassword("123456");
@BeforeAll
public static void start() {
mysql.setPortBindings(Collections.singletonList("3306:3306"));
mysql.start();
}
}

View File

@ -19,6 +19,11 @@ package com.mybatisflex.test.common;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.JSONWriter;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mybatisflex.core.query.QueryCondition;
import java.io.*;
@ -71,4 +76,26 @@ public class SerialUtil {
return parseObject(toJSONString(obj), tClass);
}
/**
* 使用jackson对QueryWrapper进行序列化反序列化操作需要注意QueryCondition的protected属性以及prev和next的递归问题
*
* @return Jackson序列化映射
*/
public static ObjectMapper jacksonMapper(){
ObjectMapper mapper = new ObjectMapper();
// 为了将QueryWrapper里的protected属性可见
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC);
// 避免QueryCondition里的prev和next在序列化时出现递归调用错误
mapper.addMixIn(QueryCondition.class,QueryConditionMixIn.class);
return mapper;
}
/**
* 因无法修改QueryCondition而添加的映射属性包装
*/
class QueryConditionMixIn{
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
protected QueryCondition prev;
}
}

View File

@ -19,18 +19,16 @@ package com.mybatisflex.test.mapper;
import com.mybatisflex.core.logicdelete.LogicDeleteManager;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.Db;
import com.mybatisflex.core.row.Row;
import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.Account;
import com.mybatisflex.test.model.AccountVO;
import com.mybatisflex.test.model.AccountVO2;
import lombok.val;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.Date;
import java.util.List;
import static com.mybatisflex.core.query.QueryMethods.*;
import static com.mybatisflex.test.model.table.AccountTableDef.ACCOUNT;
@ -44,7 +42,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
*/
@SpringBootTest
@SuppressWarnings("all")
class AccountMapperTest {
class AccountMapperTest extends TestInfrastructure {
@Autowired
private AccountMapper accountMapper;

View File

@ -18,6 +18,7 @@ package com.mybatisflex.test.mapper;
import com.mybatisflex.core.mybatis.Mappers;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.Good;
import com.mybatisflex.test.model.User;
import org.junit.jupiter.api.Assertions;
@ -34,7 +35,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
* @since 2023-07-23
*/
@SpringBootTest
class ActiveRecordTest {
class ActiveRecordTest extends TestInfrastructure {
@Test
void testMapper() {

View File

@ -17,6 +17,7 @@
package com.mybatisflex.test.mapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.Account;
import com.mybatisflex.test.model.Article;
import org.junit.jupiter.api.Test;
@ -26,7 +27,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
public class CombinedMapperTest {
public class CombinedMapperTest extends TestInfrastructure {
@Autowired
private AccountMapper accountMapper;

View File

@ -16,6 +16,7 @@
package com.mybatisflex.test.mapper;
import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.Account;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -32,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* @since 2023/4/24 19:37
*/
@SpringBootTest
class MyAccountMapperTest {
class MyAccountMapperTest extends TestInfrastructure {
@Autowired
private MyAccountMapper mapper;

View File

@ -17,7 +17,7 @@
package com.mybatisflex.test.mapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.test.entity.Inner;
import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.entity.Outer;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -32,7 +32,7 @@ import static com.mybatisflex.test.entity.table.OuterTableDef.OUTER;
* @since 2023-07-01
*/
@SpringBootTest
class OuterMapperTest {
class OuterMapperTest extends TestInfrastructure {
@Autowired
private OuterMapper outerMapper;

View File

@ -1,5 +1,6 @@
package com.mybatisflex.test.mapper;
import com.mybatisflex.test.TestInfrastructure;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@ -13,7 +14,7 @@ import javax.annotation.Resource;
*/
@SpringBootTest
@SuppressWarnings("all")
public class PatientMapperTest {
public class PatientMapperTest extends TestInfrastructure {
@Resource
private PatientMapper patientMapper;

View File

@ -20,6 +20,7 @@ import com.mybatisflex.core.field.QueryBuilder;
import com.mybatisflex.core.query.QueryChain;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.Gender;
import com.mybatisflex.test.model.User;
import org.junit.jupiter.api.Assertions;
@ -36,7 +37,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
* @since 2023-08-08
*/
@SpringBootTest
class QueryChainTest {
class QueryChainTest extends TestInfrastructure {
@Autowired
UserMapper userMapper;

View File

@ -18,6 +18,7 @@ package com.mybatisflex.test.mapper;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -42,7 +43,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
*/
@SpringBootTest
@SuppressWarnings("all")
class UserMapperTest {
class UserMapperTest extends TestInfrastructure {
@Autowired
private UserMapper userMapper;

View File

@ -17,6 +17,7 @@
package com.mybatisflex.test.service;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.test.TestInfrastructure;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@ -28,7 +29,7 @@ import static com.mybatisflex.test.model.table.ArticleTableDef.ARTICLE;
* @since 2023-07-22
*/
@SpringBootTest
class ArticleServiceTest {
class ArticleServiceTest extends TestInfrastructure {
@Autowired
ArticleService articleService;

View File

@ -2,6 +2,7 @@ package com.mybatisflex.test.service;
import com.mybatisflex.test.mapper.FieldMappingInnerMapper;
import com.mybatisflex.test.mapper.FieldMappingMapper;
import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.FieldMapping;
import com.mybatisflex.test.model.FieldMappingInner;
import org.junit.jupiter.api.Test;
@ -11,11 +12,12 @@ import org.springframework.boot.test.context.SpringBootTest;
import java.util.Date;
@SpringBootTest
public class FieldMappingTest {
class FieldMappingTest extends TestInfrastructure {
@Autowired
FieldMappingMapper fieldMappingMapper;
@Autowired
FieldMappingInnerMapper fieldMappingInnerMapper;
@Test
void testFieldMapping() {
String fieldId = FieldMapping.create().saveOpt().get().getId();

View File

@ -4,7 +4,7 @@
<parent>
<artifactId>mybatis-flex-test</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>mybatis-flex-test</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>com.mybatis-flex</groupId>
<version>1.7.6</version>
<version>1.7.7</version>
</parent>
<modelVersion>4.0.0</modelVersion>

16
pom.xml
View File

@ -7,7 +7,7 @@
<groupId>com.mybatis-flex</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.7.6</version>
<version>1.7.7</version>
<name>mybatis-flex</name>
<url>https://mybatis-flex.com</url>
@ -45,6 +45,7 @@
<module>mybatis-flex-core</module>
<module>mybatis-flex-spring</module>
<module>mybatis-flex-spring-boot-starter</module>
<module>mybatis-flex-spring-boot3-starter</module>
<module>mybatis-flex-solon-plugin</module>
<module>mybatis-flex-test</module>
<module>mybatis-flex-processor</module>
@ -55,9 +56,9 @@
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<mybatis-flex.version>1.7.6</mybatis-flex.version>
<mybatis-flex.version>1.7.7</mybatis-flex.version>
<mybatis.version>3.5.14</mybatis.version>
<mybatis.version>3.5.15</mybatis.version>
<mybatis-spring.version>2.1.2</mybatis-spring.version>
<mybatis-freemarker.version>1.2.4</mybatis-freemarker.version>
<mybatis-velocity.version>2.1.2</mybatis-velocity.version>
@ -71,6 +72,7 @@
<solon.version>2.5.3</solon.version>
<junit.version>4.13.2</junit.version>
<testcontainers.version>1.19.3</testcontainers.version>
<maven-flatten.version>1.5.0</maven-flatten.version>
</properties>
@ -188,6 +190,14 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>${testcontainers.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>