瀏覽代碼

Merge remote-tracking branch 'origin/3.0' into 3.0

# Conflicts:
#	mybatis-plus-extension/build.gradle
#	mybatis-plus-extension/src/main/kotlin/com/baomidou/mybatisplus/extension/kotlin/KtQueryChainWrapper.kt
#	mybatis-plus-extension/src/main/kotlin/com/baomidou/mybatisplus/extension/kotlin/KtUpdateChainWrapper.kt
Gozei 1 年之前
父節點
當前提交
6a28c86a75
共有 100 個文件被更改,包括 870 次插入178 次删除
  1. 49 1
      CHANGELOG.md
  2. 1 1
      LICENSE
  3. 2 0
      README-zh.md
  4. 2 0
      README.md
  5. 21 15
      build.gradle
  6. 1 2
      changelog-temp.md
  7. 1 1
      gradle.properties
  8. 5 3
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/DbType.java
  9. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/EnumValue.java
  10. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/FieldFill.java
  11. 8 3
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/FieldStrategy.java
  12. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/IEnum.java
  13. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/IdType.java
  14. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/InterceptorIgnore.java
  15. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/KeySequence.java
  16. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/OrderBy.java
  17. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/SqlCondition.java
  18. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/TableField.java
  19. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/TableId.java
  20. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/TableLogic.java
  21. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/TableName.java
  22. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/Version.java
  23. 1 1
      mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/package-info.java
  24. 1 1
      mybatis-plus-boot-starter-test/src/main/java/com/baomidou/mybatisplus/test/autoconfigure/AutoConfigureMybatisPlus.java
  25. 1 1
      mybatis-plus-boot-starter-test/src/main/java/com/baomidou/mybatisplus/test/autoconfigure/MybatisPlusTest.java
  26. 1 1
      mybatis-plus-boot-starter-test/src/main/java/com/baomidou/mybatisplus/test/autoconfigure/MybatisPlusTestContextBootstrapper.java
  27. 1 1
      mybatis-plus-boot-starter-test/src/main/java/com/baomidou/mybatisplus/test/autoconfigure/MybatisPlusTypeExcludeFilter.java
  28. 1 1
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/ConfigurationCustomizer.java
  29. 1 1
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/DdlApplicationRunner.java
  30. 1 1
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/IdentifierGeneratorAutoConfiguration.java
  31. 40 0
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisDependsOnDatabaseInitializationDetector.java
  32. 5 3
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.java
  33. 30 1
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisPlusLanguageDriverAutoConfiguration.java
  34. 1 1
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisPlusProperties.java
  35. 1 1
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisPlusPropertiesCustomizer.java
  36. 1 1
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/SafetyEncryptProcessor.java
  37. 1 1
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/SpringBootVFS.java
  38. 1 1
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/SqlSessionFactoryBeanCustomizer.java
  39. 1 1
      mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/package-info.java
  40. 6 0
      mybatis-plus-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
  41. 3 0
      mybatis-plus-boot-starter/src/main/resources/META-INF/spring.factories
  42. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/InjectorResolver.java
  43. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisConfiguration.java
  44. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisMapperAnnotationBuilder.java
  45. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisMapperRegistry.java
  46. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisMethodResolver.java
  47. 44 11
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisParameterHandler.java
  48. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisPlusVersion.java
  49. 2 2
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisSqlSessionFactoryBuilder.java
  50. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisXMLConfigBuilder.java
  51. 8 2
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisXMLLanguageDriver.java
  52. 300 0
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisXMLScriptBuilder.java
  53. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/assist/ISqlRunner.java
  54. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/assist/package-info.java
  55. 52 3
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/AbstractLambdaWrapper.java
  56. 56 27
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/AbstractWrapper.java
  57. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/ISqlSegment.java
  58. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/SharedString.java
  59. 22 5
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/Wrapper.java
  60. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/interfaces/Compare.java
  61. 38 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/interfaces/Func.java
  62. 2 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/interfaces/Join.java
  63. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/interfaces/Nested.java
  64. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/interfaces/package-info.java
  65. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/package-info.java
  66. 24 5
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/query/LambdaQueryWrapper.java
  67. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/query/Query.java
  68. 8 3
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/query/QueryWrapper.java
  69. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/query/package-info.java
  70. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/AbstractISegmentList.java
  71. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/ColumnSegment.java
  72. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/GroupBySegmentList.java
  73. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/HavingSegmentList.java
  74. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/MatchSegment.java
  75. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/MergeSegments.java
  76. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/NormalSegmentList.java
  77. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/OrderBySegmentList.java
  78. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/package-info.java
  79. 4 4
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/LambdaUpdateWrapper.java
  80. 9 5
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/Update.java
  81. 4 4
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/UpdateWrapper.java
  82. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/package-info.java
  83. 13 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/config/GlobalConfig.java
  84. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/config/package-info.java
  85. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/enums/SqlKeyword.java
  86. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/enums/SqlLike.java
  87. 6 2
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/enums/SqlMethod.java
  88. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/enums/WrapperKeyword.java
  89. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/enums/package-info.java
  90. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/exceptions/MybatisPlusException.java
  91. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/exceptions/package-info.java
  92. 15 0
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/AnnotationHandler.java
  93. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/CompositeEnumTypeHandler.java
  94. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/MetaObjectHandler.java
  95. 4 4
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/MybatisEnumTypeHandler.java
  96. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/PostInitTableInfoHandler.java
  97. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/StrictFill.java
  98. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/package-info.java
  99. 18 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/incrementer/DefaultIdentifierGenerator.java
  100. 1 1
      mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/incrementer/IKeyGenerator.java

+ 49 - 1
CHANGELOG.md

@@ -1,7 +1,55 @@
 # CHANGELOG
 
-## [v3.5.3] 2022.12.29
+## [v3.5.3.2] 2023.08.08
+
+- feat: 升级mybatis至3.5.13,mybatis-spring至2.1.1
+- feat: jsqlparser提供统一解析类,可配置解析函数,并加入缓存选项
+- feat: 增加Sequence初始化debug日志
+- feat: 参数填充器支持多参数填充
+- feat: BaseMapper新增selectMaps(page, wrapper)与selectList(page, wrapper)方法
+- feat: 乐观锁字段支持 java.time.Instant
+- feat: `wrapper#apply`支持配置`mapping`比如`column={0,javaType=int,jdbcType=NUMERIC,typeHandler=xxx.xxx.MyTypeHandler}`
+- feat: 调整 QueryWrapper 需要主动开启检查 SQL 注入过滤(移除掉wrapper的orderby的sql过滤功能)
+- feat: 新增星瑞格数据库支持
+- feat: `updateWrapper#setSql`方法支持`动态入参`参考`wrapper#apply`方法
+- feat: 自动 SQL 维护 DDL 支持 SQL 执行存储过程
+- perf: `ktWrapper`加强泛型限制
+- fix: 修复在选择springdoc文档注释时entity描述异常
+- fix: 在主键的`IdType`为`AUTO`的情况下,`Table#getAllInsertSqlColumnMaybeIf("xx.")`所生成sql错误问题
+- fix: 租户插件支持`update set subSelect`的情况
+- fix: 修复高版本Jdk提示非法反射警告(Illegal reflective access by com.baomidou.mybatisplus.core.toolkit.SetAccessibleAction)
+- fix: 修复高版本Jdk插件动态代理反射错误 (Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible)
+- fix: 修复路径替换将原有的“.”替换成了文件分隔符“/”
+- fix: 修复Beetl模板引擎无法生成注释
+- fix: 修复Types.DOUBLE类型无法映射
+- fix: 修复转换父类公共字段报错
+- fix: 修复生成器无法通过cfg.取值
+- fix: 修复单元测试下MockBean时事务回滚失败
+- fix: 修复Warpper类nonEmptyOfWhere方法命名不规范,导致Ognl未正确缓存带来的执行开销
+- fix: ClickHouseQuery类的tableComment()方法返回表注释字段为comment
+- fix: 修复在选择springdoc文档注释时entity描述异常问题
+- fix: Table\#getAllInsertSqlColumnMaybeIf("xx.")下的sql生成错误问题
+- fix: Db类增加根据实体不为空的字段条件查询方法重载
+- fix: 生成器对于Kotlin的Entity文件的superEntityClass的错误
+- fix: 修复springdoc freemarker模式下 表注释取值取不到
+- opt: 增强参数填充处理器,防止因参数名称与填充名称一致类型不匹配导致转换错误
+- opt: 优化方法注入,去除SelectPage,SelectMapsPage,SelectByMap,DeleteByMap注入
+- opt: 减少MappedStatement堆内存占用
+- opt: 解决PluginUtils重复获取元数据带来的性能消耗
+- opt: 注入方法去除多余的换行符
+- opt: 去除SqlRunner持有的sqlSessionFactory变量
+- opt: 解决Sequence初始化多次问题(自定义情况下可不创建默认主键生成器)
+- opt: 优化 SqlHelper#getMapper 返回泛型
+- opt: 去除SqlRunner持有的sqlSessionFactory变量
+- docs: 修正DdlHelper注释错误
+
+
+## [v3.5.3.1] 2022.12.29
+
 - bug:生成模块pg和dm语句模式名增加
+- feat: 优化 ChainWrapper#getEntityClass
+- fix: 修复在 IService.lambdaQuery().one() 使用场景在数据库无数据时报错问题
+- est 以及租户插件解析sql遇到多表必须给表起别名
 
 
 ## [v3.5.3] 2022.12.28

+ 1 - 1
LICENSE

@@ -186,7 +186,7 @@
       same "printed page" as the copyright notice for easier
       identification within third-party archives.
 
-   Copyright 2011-2019 hubin.
+   Copyright (c) 2011-${year}, baomidou (jobob@qq.com).
 
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.

+ 2 - 0
README-zh.md

@@ -26,6 +26,8 @@ Mybatis 增强工具包 - 只做增强不做改变,简化`CRUD`操作
 
 添加 `微信 wx153666` 备注进 mp 群
 
+> 不允许非法项目使用,后果自负
+
 # 特别用户
 
 <p>

+ 2 - 0
README.md

@@ -26,6 +26,8 @@
 
 添加 `微信 wx153666` 备注进 mp 群
 
+> 不允许非法项目使用,后果自负
+
 # Special user
 
 <p>

+ 21 - 15
build.gradle

@@ -11,25 +11,25 @@ ext {
     ]
 
     libraries = [
-        mybatisVersion = '3.5.10',
-        mybatisSpringVersion = '2.0.7',
-        mybatisSpringBootStarterVersion = '2.2.2',
+        mybatisVersion = '3.5.13',
+        mybatisSpringVersion = '2.1.1',
+        mybatisSpringBootStarterVersion = '2.3.1',
         springVersion = '5.3.15',
         springBootVersion = '2.5.3',
         springCloudVersion = '3.1.1',
-        jsqlparserVersion = '4.4', // 4.5 有bug
+        jsqlparserVersion = '4.6',
         junitVersion = '5.9.0',
     ]
 
     lib = [
-        "kotlin-reflect"             : "org.jetbrains.kotlin:kotlin-reflect:1.7.10",
-        "kotlin-stdlib-jdk8"         : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10",
+        "kotlin-reflect"             : "org.jetbrains.kotlin:kotlin-reflect:1.9.0",
+        "kotlin-stdlib-jdk8"         : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0",
         "jsqlparser"                 : "com.github.jsqlparser:jsqlparser:${jsqlparserVersion}",
         "mybatis"                    : "org.mybatis:mybatis:${mybatisVersion}",
         "mybatis-spring"             : "org.mybatis:mybatis-spring:${mybatisSpringVersion}",
         "mybatis-thymeleaf"          : "org.mybatis.scripting:mybatis-thymeleaf:1.0.3",
         "mybatis-freemarker"         : "org.mybatis.scripting:mybatis-freemarker:1.2.3",
-        "mybatis-velocity"           : "org.mybatis.scripting:mybatis-velocity:2.1.1",
+        "mybatis-velocity"           : "org.mybatis.scripting:mybatis-velocity:2.1.2",
         "spring-context-support"     : "org.springframework:spring-context-support:${springVersion}",
         "spring-jdbc"                : "org.springframework:spring-jdbc:${springVersion}",
         "spring-tx"                  : "org.springframework:spring-tx:${springVersion}",
@@ -57,7 +57,7 @@ ext {
         "p6spy"                      : "p6spy:p6spy:3.9.1",
         "sqlserver"                  : "com.microsoft.sqlserver:sqljdbc4:4.0",
         "postgresql"                 : "org.postgresql:postgresql:42.4.1",
-        "oracle"                     : fileTree(dir: 'libs', includes: ['ojdbc-11.2.0.3-jdk16.jar']),
+        "oracle"                     : fileTree(dir: 'libs', includes: ['ojdbc8.jar']),
         "dm"                         : fileTree(dir: 'libs', includes: ["jdbcDriver-18.jar"]),
         "kingbase"                   : fileTree(dir: 'libs', includes: ["kingbase8-8.2.0.jar"]),
         "h2"                         : "com.h2database:h2:2.1.214",
@@ -65,7 +65,7 @@ ext {
         "sqlite"                     : "org.xerial:sqlite-jdbc:3.39.2.0",
         "firebird"                   : "org.firebirdsql.jdbc:jaybird:4.0.6.java8",
         //cache
-        "mybatis-ehcache"            : "org.mybatis.caches:mybatis-ehcache:1.2.1",
+        "mybatis-ehcache"            : "org.mybatis.caches:mybatis-ehcache:1.2.3",
         "mybatis-redis"              : "org.mybatis.caches:mybatis-redis:1.0.0-beta2",
         "mybatis-caffeine"           : "org.mybatis.caches:mybatis-caffeine:1.0.0",
         //code generator
@@ -102,6 +102,7 @@ subprojects {
         testImplementation "${lib["junit-jupiter"]}"
         testImplementation "org.mockito:mockito-junit-jupiter:4.6.1"
         testImplementation "${lib["lagarto"]}"
+        testImplementation "${lib["logback-classic"]}"
     }
 
     tasks.withType(JavaCompile) {
@@ -178,15 +179,20 @@ subprojects {
         // 增加jvm参数不是一个很好的处理方案,最好还是只用java8下跑,下面只是兼容运行一下,但在高版本jdk下还有很多第三方反射库存在问题(等待完全升级)
         // 部分测试用例如果需要在高版本java下运行用@EnabledOnJre
         // 例如: https://github.com/cglib/cglib/issues/191
-        if (JavaVersion.current().isJava9Compatible()) {
-            jvmArgs += ["--add-opens", "java.base/java.lang=ALL-UNNAMED",
-                        "--add-opens", "java.base/java.util=ALL-UNNAMED",
-                        "--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED"]
-        }
+//        if (JavaVersion.current().isJava9Compatible()) {
+//            jvmArgs += ["--add-opens", "java.base/java.lang=ALL-UNNAMED",
+//                        "--add-opens", "java.base/java.util=ALL-UNNAMED",
+//                        "--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED"]
+//        }
         exclude("**/phoenix/**")
         exclude("**/postgresql/**")
-        exclude("**/generator/**")
+//        exclude("**/generator/**")
+    }
+
+    task cleanBuildDir(type: Delete) {
+        delete "${projectDir}/out"
     }
+    tasks.clean.dependsOn(cleanBuildDir)
 
     task javadocJar(type: Jar) {
         archiveClassifier = 'javadoc'

+ 1 - 2
changelog-temp.md

@@ -1,2 +1 @@
-fix: 修复在选择springdoc文档注释时entity描述异常
-fix: 在主键的`IdType`为`AUTO`的情况下,`Table#getAllInsertSqlColumnMaybeIf("xx.")`所生成sql错误问题
+

+ 1 - 1
gradle.properties

@@ -1,4 +1,4 @@
-APP_VERSION=3.5.3.3-SNAPSHOT
+APP_VERSION=3.5.3.2
 APP_GROUP=com.baomidou
 signing.keyId=1FD337F9
 signing.password=243194995

+ 5 - 3
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/DbType.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -118,7 +118,9 @@ public enum DbType {
      */
     @Deprecated
     GBASE_INFORMIX("gbase 8s", "南大通用数据库 GBase 8s"),
-
+    /**
+     * Sinodb
+     */
     SINODB("sinodb","星瑞格数据库"),
     /**
      * Oscar
@@ -153,7 +155,7 @@ public enum DbType {
      */
     CSIIDB("csiidb", "CSIIDB数据库"),
     /**
-     * CSIIDB
+     * Hana
      */
     SAP_HANA("hana", "SAP_HANA数据库"),
     /**

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/EnumValue.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/FieldFill.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 8 - 3
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/FieldStrategy.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,16 +18,21 @@ package com.baomidou.mybatisplus.annotation;
 /**
  * 字段策略枚举类
  * <p>
- * 如果字段是基本数据类型则最终效果等同于 {@link #IGNORED}
+ * 如果字段是基本数据类型则最终效果等同于 {@link #ALWAYS}
  *
  * @author hubin
  * @since 2016-09-09
  */
 public enum FieldStrategy {
     /**
-     * 忽略判断
+     * 忽略判断,该字段存在语义理解问题,后续版本将废弃 github issues/5129
      */
+    @Deprecated
     IGNORED,
+    /**
+     * 任何时候都加入 SQL
+     */
+    ALWAYS,
     /**
      * 非NULL判断
      */

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/IEnum.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/IdType.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/InterceptorIgnore.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/KeySequence.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/OrderBy.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/SqlCondition.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/TableField.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/TableId.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/TableLogic.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/TableName.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/Version.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter-test/src/main/java/com/baomidou/mybatisplus/test/autoconfigure/AutoConfigureMybatisPlus.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter-test/src/main/java/com/baomidou/mybatisplus/test/autoconfigure/MybatisPlusTest.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter-test/src/main/java/com/baomidou/mybatisplus/test/autoconfigure/MybatisPlusTestContextBootstrapper.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter-test/src/main/java/com/baomidou/mybatisplus/test/autoconfigure/MybatisPlusTypeExcludeFilter.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/ConfigurationCustomizer.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/DdlApplicationRunner.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/IdentifierGeneratorAutoConfiguration.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 40 - 0
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisDependsOnDatabaseInitializationDetector.java

@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.baomidou.mybatisplus.autoconfigure;
+
+import org.mybatis.spring.SqlSessionTemplate;
+import org.springframework.boot.sql.init.dependency.AbstractBeansOfTypeDependsOnDatabaseInitializationDetector;
+import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector;
+
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * {@link DependsOnDatabaseInitializationDetector} for Mybatis.
+ *
+ * @author Eddú Meléndez
+ *
+ * @since 2.3.0
+ */
+class MybatisDependsOnDatabaseInitializationDetector
+    extends AbstractBeansOfTypeDependsOnDatabaseInitializationDetector {
+
+  @Override
+  protected Set<Class<?>> getDependsOnDatabaseInitializationBeanTypes() {
+    return Collections.singleton(SqlSessionTemplate.class);
+  }
+
+}

+ 5 - 3
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -342,8 +342,10 @@ public class MybatisPlusAutoConfiguration implements InitializingBean {
             }
 
             // for spring-native
-            boolean injectSqlSession = environment.getProperty("mybatis.inject-sql-session-on-mapper-scan", Boolean.class,
-                Boolean.TRUE);
+            Boolean injectSqlSession = environment.getProperty("mybatis-plus.inject-sql-session-on-mapper-scan", Boolean.class);
+            if (injectSqlSession == null) {
+                injectSqlSession = environment.getProperty("mybatis.inject-sql-session-on-mapper-scan", Boolean.class, Boolean.TRUE);
+            }
             if (injectSqlSession && this.beanFactory instanceof ListableBeanFactory) {
                 ListableBeanFactory listableBeanFactory = (ListableBeanFactory) this.beanFactory;
                 Optional<String> sqlSessionTemplateBeanName = Optional

+ 30 - 1
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisPlusLanguageDriverAutoConfiguration.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,10 +15,14 @@
  */
 package com.baomidou.mybatisplus.autoconfigure;
 
+import com.baomidou.mybatisplus.core.MybatisParameterHandler;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.extension.scripting.MybatisFreeMarkerLanguageDriver;
 import com.baomidou.mybatisplus.extension.scripting.MybatisThymeleafLanguageDriver;
 import com.baomidou.mybatisplus.extension.scripting.MybatisVelocityLanguageDriver;
+import org.apache.ibatis.executor.parameter.ParameterHandler;
+import org.apache.ibatis.mapping.BoundSql;
+import org.apache.ibatis.mapping.MappedStatement;
 import org.apache.ibatis.scripting.LanguageDriver;
 import org.mybatis.scripting.freemarker.FreeMarkerLanguageDriver;
 import org.mybatis.scripting.freemarker.FreeMarkerLanguageDriverConfig;
@@ -49,6 +53,9 @@ public class MybatisPlusLanguageDriverAutoConfiguration {
 
     private static final String CONFIGURATION_PROPERTY_PREFIX = Constants.MYBATIS_PLUS + ".scripting-language-driver";
 
+    /**
+     * Configuration class for mybatis-freemarker 1.1.x or under.
+     */
     @Configuration
     @ConditionalOnClass(FreeMarkerLanguageDriver.class)
     @ConditionalOnMissingClass("org.mybatis.scripting.freemarker.FreeMarkerLanguageDriverConfig")
@@ -80,6 +87,28 @@ public class MybatisPlusLanguageDriverAutoConfiguration {
         }
     }
 
+    /**
+     * Configuration class for mybatis-velocity 2.0 or under.
+     */
+    @Configuration
+    @ConditionalOnClass(org.mybatis.scripting.velocity.Driver.class)
+    @ConditionalOnMissingClass("org.mybatis.scripting.velocity.VelocityLanguageDriverConfig")
+    @SuppressWarnings("deprecation")
+    public static class LegacyVelocityConfiguration {
+
+        @Bean
+        @ConditionalOnMissingBean
+        org.mybatis.scripting.velocity.Driver velocityLanguageDriver() {
+            return new org.mybatis.scripting.velocity.Driver() {
+                @Override
+                public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql) {
+                    return new MybatisParameterHandler(mappedStatement, parameterObject, boundSql);
+                }
+            };
+        }
+
+    }
+
     /**
      * Configuration class for mybatis-velocity 2.1.x or above.
      */

+ 1 - 1
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisPlusProperties.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/MybatisPlusPropertiesCustomizer.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/SafetyEncryptProcessor.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/SpringBootVFS.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/SqlSessionFactoryBeanCustomizer.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-boot-starter/src/main/java/com/baomidou/mybatisplus/autoconfigure/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 6 - 0
mybatis-plus-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json

@@ -37,6 +37,12 @@
             "description": "A default scope for mapper bean that scanned by auto-configure.",
             "type": "java.lang.String"
         },
+        {
+            "defaultValue": true,
+            "name": "mybatis-plus.inject-sql-session-on-mapper-scan",
+            "description": "Set whether inject a SqlSessionTemplate or SqlSessionFactory bean (If you want to back to the behavior of 2.2.1 or before, specify false). If you use together with spring-native, should be set true.",
+            "type": "java.lang.Boolean"
+        },
         {
             "sourceType": "com.baomidou.mybatisplus.core.config.GlobalConfig",
             "name": "mybatis-plus.global-config.identifier-generator",

+ 3 - 0
mybatis-plus-boot-starter/src/main/resources/META-INF/spring.factories

@@ -5,3 +5,6 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
   com.baomidou.mybatisplus.autoconfigure.IdentifierGeneratorAutoConfiguration,\
   com.baomidou.mybatisplus.autoconfigure.MybatisPlusLanguageDriverAutoConfiguration,\
   com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration
+# Depends On Database Initialization Detectors
+org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector=\
+com.baomidou.mybatisplus.autoconfigure.MybatisDependsOnDatabaseInitializationDetector

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/InjectorResolver.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisConfiguration.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisMapperAnnotationBuilder.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisMapperRegistry.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisMethodResolver.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 44 - 11
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisParameterHandler.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
 import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
 import com.baomidou.mybatisplus.core.metadata.TableInfo;
 import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
+import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -38,8 +39,10 @@ import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -51,6 +54,8 @@ import java.util.Map;
  */
 public class MybatisParameterHandler implements ParameterHandler {
 
+    public static final String[] COLLECTION_KEYS = new String[]{"collection", "coll", "list", "array"};
+
     private final TypeHandlerRegistry typeHandlerRegistry;
     private final MappedStatement mappedStatement;
     private final Object parameterObject;
@@ -75,13 +80,7 @@ public class MybatisParameterHandler implements ParameterHandler {
             if (SimpleTypeRegistry.isSimpleType(parameter.getClass())) {
                 return parameter;
             }
-            Collection<Object> parameters = getParameters(parameter);
-            if (null != parameters) {
-                // 感觉这里可以稍微优化一下,理论上都是同一个.
-                parameters.forEach(this::process);
-            } else {
-                process(parameter);
-            }
+            extractParameters(parameter).forEach(this::process);
         }
         return parameter;
     }
@@ -183,12 +182,16 @@ public class MybatisParameterHandler implements ParameterHandler {
      * </p>
      *
      * @return 集合参数
+     * @deprecated 3.5.3.2
      */
     @SuppressWarnings({"rawtypes", "unchecked"})
+    @Deprecated
     protected Collection<Object> getParameters(Object parameterObject) {
         Collection<Object> parameters = null;
         if (parameterObject instanceof Collection) {
             parameters = (Collection) parameterObject;
+        } else if (ArrayUtils.isArray(parameterObject)) {
+            parameters = toCollection(parameterObject);
         } else if (parameterObject instanceof Map) {
             Map parameterMap = (Map) parameterObject;
             // 约定 coll collection list array 这四个特殊key值处理批量.
@@ -207,18 +210,48 @@ public class MybatisParameterHandler implements ParameterHandler {
         return parameters;
     }
 
+    /**
+     * 提取特殊key值 (只支持外层参数,嵌套参数不考虑)
+     * List<Map>虽然这种写法目前可以进去提取et,但不考虑再提取list等其他类型,只做简单参数提取
+     *
+     * @param parameterObject 参数
+     * @return 预期可能为填充参数值
+     */
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    private Collection<Object> extractParameters(Object parameterObject) {
+        Collection<Object> parameters = new ArrayList<>();
+        if (parameterObject instanceof Collection) {
+            parameters = (Collection) parameterObject;
+        } else if (ArrayUtils.isArray(parameterObject)) {
+            parameters = toCollection(parameterObject);
+        } else if (parameterObject instanceof Map) {
+            Map parameterMap = (Map) parameterObject;
+            if (parameterMap.containsKey(Constants.ENTITY)) {
+                parameters.add(parameterMap.get(Constants.ENTITY));
+            }
+            for (String key : COLLECTION_KEYS) {
+                if (parameterMap.containsKey(key)) {
+                    parameters.addAll(toCollection(parameterMap.get(key)));
+                }
+            }
+        } else {
+            parameters.add(parameterObject);
+        }
+        return parameters;
+    }
+
     @SuppressWarnings("unchecked")
     protected Collection<Object> toCollection(Object value) {
         if (value == null) {
-            return null;
+            return Collections.emptyList();
         }
         // 只处理array和collection
-        if (value.getClass().isArray()) {
+        if (ArrayUtils.isArray(value)) {
             return Arrays.asList((Object[]) value);
         } else if (Collection.class.isAssignableFrom(value.getClass())) {
             return (Collection<Object>) value;
         }
-        return null;
+        return Collections.emptyList();
     }
 
     @Override

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisPlusVersion.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 2 - 2
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisSqlSessionFactoryBuilder.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@ public class MybatisSqlSessionFactoryBuilder extends SqlSessionFactoryBuilder {
 
         final IdentifierGenerator identifierGenerator;
         if (null == globalConfig.getIdentifierGenerator()) {
-            identifierGenerator = new DefaultIdentifierGenerator();
+            identifierGenerator = DefaultIdentifierGenerator.getInstance();
             globalConfig.setIdentifierGenerator(identifierGenerator);
         } else {
             identifierGenerator = globalConfig.getIdentifierGenerator();

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisXMLConfigBuilder.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 8 - 2
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisXMLLanguageDriver.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import org.apache.ibatis.executor.parameter.ParameterHandler;
 import org.apache.ibatis.mapping.BoundSql;
 import org.apache.ibatis.mapping.MappedStatement;
 import org.apache.ibatis.mapping.SqlSource;
+import org.apache.ibatis.parsing.XNode;
 import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver;
 import org.apache.ibatis.session.Configuration;
 
@@ -45,10 +46,15 @@ public class MybatisXMLLanguageDriver extends XMLLanguageDriver {
         return new MybatisParameterHandler(mappedStatement, parameterObject, boundSql);
     }
 
+    @Override
+    public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType) {
+        MybatisXMLScriptBuilder builder = new MybatisXMLScriptBuilder(configuration, script, parameterType);
+        return builder.parseScriptNode();
+    }
+
     @Override
     public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType) {
         GlobalConfig.DbConfig config = GlobalConfigUtils.getDbConfig(configuration);
-        script = script.replaceAll("\r", "").replaceAll("\n", "");
         if (config.isReplacePlaceholder()) {
             List<String> find = SqlUtils.findPlaceholder(script);
             if (CollectionUtils.isNotEmpty(find)) {

+ 300 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisXMLScriptBuilder.java

@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.baomidou.mybatisplus.core;
+
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import org.apache.ibatis.builder.BaseBuilder;
+import org.apache.ibatis.builder.BuilderException;
+import org.apache.ibatis.mapping.SqlSource;
+import org.apache.ibatis.parsing.XNode;
+import org.apache.ibatis.scripting.defaults.RawSqlSource;
+import org.apache.ibatis.scripting.xmltags.ChooseSqlNode;
+import org.apache.ibatis.scripting.xmltags.DynamicSqlSource;
+import org.apache.ibatis.scripting.xmltags.ForEachSqlNode;
+import org.apache.ibatis.scripting.xmltags.IfSqlNode;
+import org.apache.ibatis.scripting.xmltags.MixedSqlNode;
+import org.apache.ibatis.scripting.xmltags.SetSqlNode;
+import org.apache.ibatis.scripting.xmltags.SqlNode;
+import org.apache.ibatis.scripting.xmltags.StaticTextSqlNode;
+import org.apache.ibatis.scripting.xmltags.TextSqlNode;
+import org.apache.ibatis.scripting.xmltags.TrimSqlNode;
+import org.apache.ibatis.scripting.xmltags.VarDeclSqlNode;
+import org.apache.ibatis.scripting.xmltags.WhereSqlNode;
+import org.apache.ibatis.scripting.xmltags.XMLScriptBuilder;
+import org.apache.ibatis.session.Configuration;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+/**
+ * <p>试验性功能,解决mybatis堆内存过大的问题(看后期mybatis官方会不会解决堆内存占用问题)</p>
+ * <p>由于大量重复sql节点,导致堆内存过大(本质上属于string导致的堆内存增大问题)</p>
+ * <p>例如: {@code <if test="createTime!=null">create_time=#{createTime}</if>}等公共字段</p>
+ * <p>
+ * 解决方案:  将生成的xml节点值写入字符串常量池,减少后面重复字符串导致的问题
+ * <li>
+ * 方案一: 缓存一些特定的mybatis-plus生成的占位符与表达式和项目公共字段(改动有点多,需要增加一些特定xml属性来标记是mybatis-plus生成的节点,减少堆内存较少)
+ * </li>
+ * <li>
+ * 方案二: 直接将节点内容intern写入至字符串常量池(改动少,减少堆内存多,弊端可能会将一些无重复的字符串写入至常量池)
+ * </li>
+ * <li>
+ * 方案三: 模拟字符串常量池,减少重复字符串写入至堆内存(代码相对来说不好看点)
+ * </li>
+ * </p>
+ *
+ * @author nieqiurong
+ * @see XMLScriptBuilder
+ * @since 3.5.3.2
+ */
+public class MybatisXMLScriptBuilder extends BaseBuilder {
+
+    private final XNode context;
+    private boolean isDynamic;
+    private final Class<?> parameterType;
+    private final Map<String, NodeHandler> nodeHandlerMap = new HashMap<>();
+    private static final Map<String, WeakReference<String>> CACHE_STRING = new WeakHashMap<>();
+
+    public MybatisXMLScriptBuilder(Configuration configuration, XNode context) {
+        this(configuration, context, null);
+    }
+
+    public MybatisXMLScriptBuilder(Configuration configuration, XNode context, Class<?> parameterType) {
+        super(configuration);
+        this.context = context;
+        this.parameterType = parameterType;
+        initNodeHandlerMap();
+    }
+
+    private void initNodeHandlerMap() {
+        nodeHandlerMap.put("trim", new TrimHandler());
+        nodeHandlerMap.put("where", new WhereHandler());
+        nodeHandlerMap.put("set", new SetHandler());
+        nodeHandlerMap.put("foreach", new ForEachHandler());
+        nodeHandlerMap.put("if", new IfHandler());
+        nodeHandlerMap.put("choose", new ChooseHandler());
+        nodeHandlerMap.put("when", new IfHandler());
+        nodeHandlerMap.put("otherwise", new OtherwiseHandler());
+        nodeHandlerMap.put("bind", new BindHandler());
+    }
+
+    public SqlSource parseScriptNode() {
+        MixedSqlNode rootSqlNode = parseDynamicTags(context);
+        SqlSource sqlSource;
+        if (isDynamic) {
+            sqlSource = new DynamicSqlSource(configuration, rootSqlNode);
+        } else {
+            sqlSource = new RawSqlSource(configuration, rootSqlNode, parameterType);
+        }
+        return sqlSource;
+    }
+
+    /**
+     * 也可以将XNode节点包裹增强一下,来减少方法的引用,但需要创建对象,这里就直接将每个地方手动改一下了.
+     */
+    private synchronized static String cacheStr(String str) {
+        if (str == null) {
+            return null;
+        }
+        String value = CACHE_STRING.computeIfAbsent(str, WeakReference::new).get();
+        //增强安全处理一下,如果实在是GC处理掉了(可能性小),就返回原来.
+        if (StringUtils.isNotBlank(value)) {
+            return value;
+        }
+        return str;
+    }
+
+
+    protected MixedSqlNode parseDynamicTags(XNode node) {
+        List<SqlNode> contents = new ArrayList<>();
+        NodeList children = node.getNode().getChildNodes();
+        for (int i = 0; i < children.getLength(); i++) {
+            XNode child = node.newXNode(children.item(i));
+            if (child.getNode().getNodeType() == Node.CDATA_SECTION_NODE || child.getNode().getNodeType() == Node.TEXT_NODE) {
+                String text = cacheStr(child.getStringBody(""));
+                TextSqlNode textSqlNode = new TextSqlNode(text);
+                if (textSqlNode.isDynamic()) {
+                    contents.add(textSqlNode);
+                    isDynamic = true;
+                } else {
+                    contents.add(new StaticTextSqlNode(text));
+                }
+            } else if (child.getNode().getNodeType() == Node.ELEMENT_NODE) { // issue #628
+                String nodeName = child.getNode().getNodeName();
+                NodeHandler handler = nodeHandlerMap.get(nodeName);
+                if (handler == null) {
+                    throw new BuilderException("Unknown element <" + nodeName + "> in SQL statement.");
+                }
+                handler.handleNode(child, contents);
+                isDynamic = true;
+            }
+        }
+        return new MixedSqlNode(contents);
+    }
+
+    private interface NodeHandler {
+        void handleNode(XNode nodeToHandle, List<SqlNode> targetContents);
+    }
+
+    private class BindHandler implements NodeHandler {
+        public BindHandler() {
+            // Prevent Synthetic Access
+        }
+
+        @Override
+        public void handleNode(XNode nodeToHandle, List<SqlNode> targetContents) {
+            final String name = cacheStr(nodeToHandle.getStringAttribute("name"));
+            final String expression = cacheStr(nodeToHandle.getStringAttribute("value"));
+            final VarDeclSqlNode node = new VarDeclSqlNode(name, expression);
+            targetContents.add(node);
+        }
+    }
+
+    private class TrimHandler implements NodeHandler {
+        public TrimHandler() {
+            // Prevent Synthetic Access
+        }
+
+        @Override
+        public void handleNode(XNode nodeToHandle, List<SqlNode> targetContents) {
+            MixedSqlNode mixedSqlNode = parseDynamicTags(nodeToHandle);
+            String prefix = cacheStr(nodeToHandle.getStringAttribute("prefix"));
+            String prefixOverrides = cacheStr(nodeToHandle.getStringAttribute("prefixOverrides"));
+            String suffix = cacheStr(nodeToHandle.getStringAttribute("suffix"));
+            String suffixOverrides = cacheStr(nodeToHandle.getStringAttribute("suffixOverrides"));
+            TrimSqlNode trim = new TrimSqlNode(configuration, mixedSqlNode, prefix, prefixOverrides, suffix, suffixOverrides);
+            targetContents.add(trim);
+        }
+    }
+
+    private class WhereHandler implements NodeHandler {
+        public WhereHandler() {
+            // Prevent Synthetic Access
+        }
+
+        @Override
+        public void handleNode(XNode nodeToHandle, List<SqlNode> targetContents) {
+            MixedSqlNode mixedSqlNode = parseDynamicTags(nodeToHandle);
+            WhereSqlNode where = new WhereSqlNode(configuration, mixedSqlNode);
+            targetContents.add(where);
+        }
+    }
+
+    private class SetHandler implements NodeHandler {
+        public SetHandler() {
+            // Prevent Synthetic Access
+        }
+
+        @Override
+        public void handleNode(XNode nodeToHandle, List<SqlNode> targetContents) {
+            MixedSqlNode mixedSqlNode = parseDynamicTags(nodeToHandle);
+            SetSqlNode set = new SetSqlNode(configuration, mixedSqlNode);
+            targetContents.add(set);
+        }
+    }
+
+    private class ForEachHandler implements NodeHandler {
+        public ForEachHandler() {
+            // Prevent Synthetic Access
+        }
+
+        @Override
+        public void handleNode(XNode nodeToHandle, List<SqlNode> targetContents) {
+            MixedSqlNode mixedSqlNode = parseDynamicTags(nodeToHandle);
+            String collection = cacheStr(nodeToHandle.getStringAttribute("collection"));
+            Boolean nullable = nodeToHandle.getBooleanAttribute("nullable");
+            String item = cacheStr(nodeToHandle.getStringAttribute("item"));
+            String index = cacheStr(nodeToHandle.getStringAttribute("index"));
+            String open = cacheStr(nodeToHandle.getStringAttribute("open"));
+            String close = cacheStr(nodeToHandle.getStringAttribute("close"));
+            String separator = cacheStr(nodeToHandle.getStringAttribute("separator"));
+            ForEachSqlNode forEachSqlNode = new ForEachSqlNode(configuration, mixedSqlNode, collection, nullable, index, item, open, close, separator);
+            targetContents.add(forEachSqlNode);
+        }
+    }
+
+    private class IfHandler implements NodeHandler {
+        public IfHandler() {
+            // Prevent Synthetic Access
+        }
+
+        @Override
+        public void handleNode(XNode nodeToHandle, List<SqlNode> targetContents) {
+            MixedSqlNode mixedSqlNode = parseDynamicTags(nodeToHandle);
+            String test = cacheStr(nodeToHandle.getStringAttribute("test"));
+            IfSqlNode ifSqlNode = new IfSqlNode(mixedSqlNode, test);
+            targetContents.add(ifSqlNode);
+        }
+    }
+
+    private class OtherwiseHandler implements NodeHandler {
+        public OtherwiseHandler() {
+            // Prevent Synthetic Access
+        }
+
+        @Override
+        public void handleNode(XNode nodeToHandle, List<SqlNode> targetContents) {
+            MixedSqlNode mixedSqlNode = parseDynamicTags(nodeToHandle);
+            targetContents.add(mixedSqlNode);
+        }
+    }
+
+    private class ChooseHandler implements NodeHandler {
+        public ChooseHandler() {
+            // Prevent Synthetic Access
+        }
+
+        @Override
+        public void handleNode(XNode nodeToHandle, List<SqlNode> targetContents) {
+            List<SqlNode> whenSqlNodes = new ArrayList<>();
+            List<SqlNode> otherwiseSqlNodes = new ArrayList<>();
+            handleWhenOtherwiseNodes(nodeToHandle, whenSqlNodes, otherwiseSqlNodes);
+            SqlNode defaultSqlNode = getDefaultSqlNode(otherwiseSqlNodes);
+            ChooseSqlNode chooseSqlNode = new ChooseSqlNode(whenSqlNodes, defaultSqlNode);
+            targetContents.add(chooseSqlNode);
+        }
+
+        private void handleWhenOtherwiseNodes(XNode chooseSqlNode, List<SqlNode> ifSqlNodes, List<SqlNode> defaultSqlNodes) {
+            List<XNode> children = chooseSqlNode.getChildren();
+            for (XNode child : children) {
+                String nodeName = child.getNode().getNodeName();
+                NodeHandler handler = nodeHandlerMap.get(nodeName);
+                if (handler instanceof IfHandler) {
+                    handler.handleNode(child, ifSqlNodes);
+                } else if (handler instanceof OtherwiseHandler) {
+                    handler.handleNode(child, defaultSqlNodes);
+                }
+            }
+        }
+
+        private SqlNode getDefaultSqlNode(List<SqlNode> defaultSqlNodes) {
+            SqlNode defaultSqlNode = null;
+            if (defaultSqlNodes.size() == 1) {
+                defaultSqlNode = defaultSqlNodes.get(0);
+            } else if (defaultSqlNodes.size() > 1) {
+                throw new BuilderException("Too many default (otherwise) elements in choose statement.");
+            }
+            return defaultSqlNode;
+        }
+    }
+
+}

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/assist/ISqlRunner.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/assist/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 52 - 3
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/AbstractLambdaWrapper.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
 package com.baomidou.mybatisplus.core.conditions;
 
 import com.baomidou.mybatisplus.core.toolkit.Assert;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.baomidou.mybatisplus.core.toolkit.support.ColumnCache;
@@ -23,7 +24,6 @@ import com.baomidou.mybatisplus.core.toolkit.support.LambdaMeta;
 import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
 import org.apache.ibatis.reflection.property.PropertyNamer;
 
-import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
@@ -51,7 +51,7 @@ public abstract class AbstractLambdaWrapper<T, Children extends AbstractLambdaWr
 
     @SafeVarargs
     protected final String columnsToString(boolean onlyColumn, SFunction<T, ?>... columns) {
-        return columnsToString(onlyColumn, Arrays.asList(columns));
+        return columnsToString(onlyColumn, CollectionUtils.toList(columns));
     }
 
     protected final String columnsToString(boolean onlyColumn, List<SFunction<T, ?>> columns) {
@@ -68,6 +68,55 @@ public abstract class AbstractLambdaWrapper<T, Children extends AbstractLambdaWr
         return onlyColumn ? cache.getColumn() : cache.getColumnSelect();
     }
 
+    @Override
+    @SafeVarargs
+    public final Children groupBy(boolean condition, SFunction<T, ?> column, SFunction<T, ?>... columns) {
+        return super.groupBy(condition, column, columns);
+    }
+
+    @Override
+    @SafeVarargs
+    public final Children orderBy(boolean condition, boolean isAsc, SFunction<T, ?> column, SFunction<T, ?>... columns) {
+        return orderBy(condition, isAsc, column, CollectionUtils.toList(columns));
+    }
+
+    @Override
+    @SafeVarargs
+    public final Children groupBy(SFunction<T, ?> column, SFunction<T, ?>... columns) {
+        return doGroupBy(true, column, CollectionUtils.toList(columns));
+    }
+
+
+    @Override
+    public Children groupBy(boolean condition, SFunction<T, ?> column, List<SFunction<T, ?>> columns) {
+        return doGroupBy(condition,column,columns);
+    }
+
+    @Override
+    @SafeVarargs
+    public final Children orderByAsc(SFunction<T, ?> column, SFunction<T, ?>... columns) {
+        return super.orderByAsc(column, columns);
+    }
+
+    @Override
+    @SafeVarargs
+    public final Children orderByAsc(boolean condition, SFunction<T, ?> column, SFunction<T, ?>... columns) {
+        return super.orderByAsc(condition, column, columns);
+    }
+
+    @Override
+    @SafeVarargs
+    public final Children orderByDesc(SFunction<T, ?> column, SFunction<T, ?>... columns) {
+        return super.orderByDesc(column, columns);
+    }
+
+    @Override
+    @SafeVarargs
+    public final Children orderByDesc(boolean condition, SFunction<T, ?> column, SFunction<T, ?>... columns) {
+        return super.orderByDesc(condition, column, columns);
+    }
+
+
     /**
      * 获取 SerializedLambda 对应的列信息,从 lambda 表达式中推测实体类
      * <p>

+ 56 - 27
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/AbstractWrapper.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,11 +28,14 @@ import com.baomidou.mybatisplus.core.toolkit.*;
 import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils;
 import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;
 import com.baomidou.mybatisplus.core.toolkit.sql.StringEscape;
+import lombok.Getter;
 
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.BiPredicate;
 import java.util.function.Consumer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import static com.baomidou.mybatisplus.core.enums.SqlKeyword.*;
 import static com.baomidou.mybatisplus.core.enums.WrapperKeyword.APPLY;
@@ -56,6 +59,7 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
      * 必要度量
      */
     protected AtomicInteger paramNameSeq;
+    @Getter
     protected Map<String, Object> paramNameValuePairs;
     /**
      * 其他
@@ -237,8 +241,7 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
 
     @Override
     public Children apply(boolean condition, String applySql, Object... values) {
-        return maybeDo(condition, () -> appendSqlSegments(APPLY,
-            () -> formatSqlMaybeWithParam(applySql, null, values)));
+        return maybeDo(condition, () -> appendSqlSegments(APPLY, () -> formatSqlMaybeWithParam(applySql, values)));
     }
 
     @Override
@@ -268,7 +271,7 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
     @Override
     public Children exists(boolean condition, String existsSql, Object... values) {
         return maybeDo(condition, () -> appendSqlSegments(EXISTS,
-            () -> String.format("(%s)", formatSqlMaybeWithParam(existsSql, null, values))));
+            () -> String.format("(%s)", formatSqlMaybeWithParam(existsSql, values))));
     }
 
     @Override
@@ -344,9 +347,21 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
 
     @Override
     public Children groupBy(boolean condition, R column, R... columns) {
+        return doGroupBy(condition, column, CollectionUtils.toList(columns));
+    }
+
+    @Override
+    public Children groupBy(boolean condition, R column, List<R> columns) {
+        return doGroupBy(condition, column, columns);
+    }
+
+    public Children doGroupBy(boolean condition, R column, List<R> columns) {
         return maybeDo(condition, () -> {
-            String one = columnToString(column);
-            if (ArrayUtils.isNotEmpty(columns)) {
+            String one = StringPool.EMPTY;
+            if (column != null) {
+                one = columnToString(column);
+            }
+            if (CollectionUtils.isNotEmpty(columns)) {
                 one += (StringPool.COMMA + columnsToString(columns));
             }
             final String finalOne = one;
@@ -354,18 +369,30 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
         });
     }
 
-    @Override
-    public Children orderBy(boolean condition, boolean isAsc, R column, R... columns) {
+
+    public Children doOrderBy(boolean condition, boolean isAsc, R column, List<R> columns){
         return maybeDo(condition, () -> {
             final SqlKeyword mode = isAsc ? ASC : DESC;
-            appendSqlSegments(ORDER_BY, columnToSqlSegment(column), mode);
-            if (ArrayUtils.isNotEmpty(columns)) {
-                Arrays.stream(columns).forEach(c -> appendSqlSegments(ORDER_BY,
+            if (column != null) {
+                appendSqlSegments(ORDER_BY, columnToSqlSegment(column), mode);
+            }
+            if (CollectionUtils.isNotEmpty(columns)) {
+                columns.forEach(c -> appendSqlSegments(ORDER_BY,
                     columnToSqlSegment(c), mode));
             }
         });
     }
 
+    @Override
+    public Children orderBy(boolean condition, boolean isAsc, R column, R... columns) {
+        return doOrderBy(condition, isAsc, column, CollectionUtils.toList(columns));
+    }
+
+    @Override
+    public Children orderBy(boolean condition, boolean isAsc, R column, List<R> columns) {
+        return doOrderBy(condition, isAsc, column, columns);
+    }
+
     @Override
     public Children groupBy(boolean condition, R column) {
         return maybeDo(condition, () -> appendSqlSegments(GROUP_BY, () -> columnToString(column)));
@@ -390,8 +417,7 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
 
     @Override
     public Children having(boolean condition, String sqlHaving, Object... params) {
-        return maybeDo(condition, () -> appendSqlSegments(HAVING,
-            () -> formatSqlMaybeWithParam(sqlHaving, null, params)));
+        return maybeDo(condition, () -> appendSqlSegments(HAVING, () -> formatSqlMaybeWithParam(sqlHaving, params)));
     }
 
     @Override
@@ -459,22 +485,30 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
      * 格式化 sql
      * <p>
      * 支持 "{0}" 这种,或者 "sql {0} sql" 这种
+     * 也支持 "sql {0,javaType=int,jdbcType=NUMERIC,typeHandler=xxx.xxx.MyTypeHandler} sql" 这种
      *
-     * @param sqlStr  可能是sql片段
-     * @param mapping 例如: "javaType=int,jdbcType=NUMERIC,typeHandler=xxx.xxx.MyTypeHandler" 这种
-     * @param params  参数
+     * @param sqlStr 可能是sql片段
+     * @param params 参数
      * @return sql片段
      */
     @SuppressWarnings("SameParameterValue")
-    protected final String formatSqlMaybeWithParam(String sqlStr, String mapping, Object... params) {
+    protected final String formatSqlMaybeWithParam(String sqlStr, Object... params) {
         if (StringUtils.isBlank(sqlStr)) {
-            // todo 何时会这样?
             return null;
         }
         if (ArrayUtils.isNotEmpty(params)) {
             for (int i = 0; i < params.length; ++i) {
-                final String target = Constants.LEFT_BRACE + i + Constants.RIGHT_BRACE;
-                sqlStr = sqlStr.replace(target, formatParam(mapping, params[i]));
+                String target = Constants.LEFT_BRACE + i + Constants.RIGHT_BRACE;
+                if (sqlStr.contains(target)) {
+                    sqlStr = sqlStr.replace(target, formatParam(null, params[i]));
+                } else {
+                    Matcher matcher = Pattern.compile("[{]" + i + ",[a-zA-Z0-9.,=]+}").matcher(sqlStr);
+                    if (!matcher.find()) {
+                        throw ExceptionUtils.mpe("Please check the syntax correctness! sql not contains: \"%s\"", target);
+                    }
+                    String group = matcher.group();
+                    sqlStr = sqlStr.replace(group, formatParam(group.substring(target.length(), group.length() - 1), params[i]));
+                }
             }
         }
         return sqlStr;
@@ -576,9 +610,8 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
         if (StringUtils.isBlank(_sqlSegment)) {
             return true;
         }
-        final String _sqlSegmentToUpperCase = _sqlSegment.toUpperCase();
-        return !(_sqlSegmentToUpperCase.contains(Constants.ORDER_BY)
-            || _sqlSegmentToUpperCase.contains(Constants.LIMIT));
+        final String _sqlSegmentUpper = _sqlSegment.toUpperCase();
+        return !(_sqlSegmentUpper.contains(Constants.ORDER_BY) || _sqlSegmentUpper.contains(Constants.LIMIT));
     }
 
     @Override
@@ -607,10 +640,6 @@ public abstract class AbstractWrapper<T, R, Children extends AbstractWrapper<T,
         return expression;
     }
 
-    public Map<String, Object> getParamNameValuePairs() {
-        return paramNameValuePairs;
-    }
-
     public String getParamAlias() {
         return paramAlias == null ? Constants.WRAPPER : paramAlias.getStringValue();
     }

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/ISqlSegment.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/SharedString.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 22 - 5
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/Wrapper.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -98,10 +98,15 @@ public abstract class Wrapper<T> implements ISqlSegment {
     /**
      * 查询条件不为空(包含entity)
      */
-    public boolean nonEmptyOfWhere() {
+    public boolean isNonEmptyOfWhere() {
         return !isEmptyOfWhere();
     }
 
+    @Deprecated
+    public boolean nonEmptyOfWhere() {
+        return isNonEmptyOfWhere();
+    }
+
     /**
      * 查询条件为空(不包含entity)
      */
@@ -112,16 +117,21 @@ public abstract class Wrapper<T> implements ISqlSegment {
     /**
      * 查询条件为空(不包含entity)
      */
-    public boolean nonEmptyOfNormal() {
+    public boolean isNonEmptyOfNormal() {
         return !isEmptyOfNormal();
     }
 
+    @Deprecated
+    public boolean nonEmptyOfNormal() {
+        return isNonEmptyOfNormal();
+    }
+
     /**
      * 深层实体判断属性
      *
      * @return true 不为空
      */
-    public boolean nonEmptyOfEntity() {
+    public boolean isNonEmptyOfEntity() {
         T entity = getEntity();
         if (entity == null) {
             return false;
@@ -136,6 +146,11 @@ public abstract class Wrapper<T> implements ISqlSegment {
         return StringUtils.isNotBlank(tableInfo.getKeyProperty()) ? Objects.nonNull(tableInfo.getPropertyValue(entity, tableInfo.getKeyProperty())) : false;
     }
 
+    @Deprecated
+    public boolean nonEmptyOfEntity() {
+        return isNonEmptyOfEntity();
+    }
+
     /**
      * 根据实体FieldStrategy属性来决定判断逻辑
      */
@@ -145,6 +160,8 @@ public abstract class Wrapper<T> implements ISqlSegment {
                 return Objects.nonNull(tableInfo.getPropertyValue(entity, e.getProperty()));
             case IGNORED:
                 return true;
+            case ALWAYS:
+                return true;
             case NOT_EMPTY:
                 return StringUtils.checkValNotNull(tableInfo.getPropertyValue(entity, e.getProperty()));
             case NEVER:
@@ -160,7 +177,7 @@ public abstract class Wrapper<T> implements ISqlSegment {
      * @return true 为空
      */
     public boolean isEmptyOfEntity() {
-        return !nonEmptyOfEntity();
+        return !isNonEmptyOfEntity();
     }
 
     /**

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/interfaces/Compare.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 38 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/interfaces/Func.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
  */
 package com.baomidou.mybatisplus.core.conditions.interfaces;
 
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.List;
@@ -294,6 +296,13 @@ public interface Func<Children, R> extends Serializable {
      */
     Children groupBy(boolean condition, R column, R... columns);
 
+    /**
+     * 分组:GROUP BY 字段, ...
+     * @since 3.5.4
+     */
+    Children groupBy(boolean condition, R column, List<R> columns);
+
+
     /**
      * 排序:ORDER BY 字段, ... ASC
      * <p>例: orderByAsc(true, "id")</p>
@@ -337,6 +346,15 @@ public interface Func<Children, R> extends Serializable {
         return orderBy(condition, true, column, columns);
     }
 
+    /**
+     * 排序:ORDER BY 字段, ... ASC
+     *
+     * @since 3.5.4
+     */
+    default Children orderByAsc(boolean condition, R column, List<R> columns) {
+        return orderBy(condition, true, column, columns);
+    }
+
     /**
      * 排序:ORDER BY 字段, ... DESC
      * <p>例: orderByDesc(true, "id")</p>
@@ -377,9 +395,19 @@ public interface Func<Children, R> extends Serializable {
      * 排序:ORDER BY 字段, ... DESC
      */
     default Children orderByDesc(boolean condition, R column, R... columns) {
+        return orderBy(condition, false, column, CollectionUtils.toList(columns));
+    }
+
+    /**
+     * 排序:ORDER BY 字段, ... DESC
+     *
+     * @since 3.5.4
+     */
+    default Children orderByDesc(boolean condition, R column, List<R> columns) {
         return orderBy(condition, false, column, columns);
     }
 
+
     /**
      * 排序:ORDER BY 字段, ...
      * <p>例: orderBy(true, "id")</p>
@@ -407,6 +435,15 @@ public interface Func<Children, R> extends Serializable {
      */
     Children orderBy(boolean condition, boolean isAsc, R column, R... columns);
 
+
+    /**
+     * 排序:ORDER BY 字段, ...
+     *
+     * @since 3.5.4
+     */
+    Children orderBy(boolean condition, boolean isAsc, R column, List<R> columns);
+
+
     /**
      * ignore
      */

+ 2 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/interfaces/Join.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,6 +54,7 @@ public interface Join<Children> extends Serializable {
      * <p>例1: apply("id = 1")</p>
      * <p>例2: apply("date_format(dateColumn,'%Y-%m-%d') = '2008-08-08'")</p>
      * <p>例3: apply("date_format(dateColumn,'%Y-%m-%d') = {0}", LocalDate.now())</p>
+     * <p>例4: apply("name={0,javaType=int,jdbcType=NUMERIC,typeHandler=xxx.xxx.MyTypeHandler}", "老王")</p>
      *
      * @param condition 执行条件
      * @param values    数据数组

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/interfaces/Nested.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/interfaces/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 24 - 5
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/query/LambdaQueryWrapper.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -75,10 +75,7 @@ public class LambdaQueryWrapper<T> extends AbstractLambdaWrapper<T, LambdaQueryW
 
     @Override
     public LambdaQueryWrapper<T> select(boolean condition, List<SFunction<T, ?>> columns) {
-        if (condition && CollectionUtils.isNotEmpty(columns)) {
-            this.sqlSelect.setStringValue(columnsToString(false, columns));
-        }
-        return typedThis;
+        return doSelect(condition, columns);
     }
 
     /**
@@ -104,6 +101,28 @@ public class LambdaQueryWrapper<T> extends AbstractLambdaWrapper<T, LambdaQueryW
         return typedThis;
     }
 
+    @Override
+    @SafeVarargs
+    public final LambdaQueryWrapper<T> select(SFunction<T, ?>... columns) {
+        return doSelect(true, CollectionUtils.toList(columns));
+    }
+
+    @Override
+    @SafeVarargs
+    public final LambdaQueryWrapper<T> select(boolean condition, SFunction<T, ?>... columns) {
+        return doSelect(condition, CollectionUtils.toList(columns));
+    }
+
+    /**
+     * @since 3.5.4
+     */
+    protected LambdaQueryWrapper<T> doSelect(boolean condition, List<SFunction<T, ?>> columns) {
+        if (condition && CollectionUtils.isNotEmpty(columns)) {
+            this.sqlSelect.setStringValue(columnsToString(false, columns));
+        }
+        return typedThis;
+    }
+
     @Override
     public String getSqlSelect() {
         return sqlSelect.getStringValue();

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/query/Query.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 8 - 3
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/query/QueryWrapper.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,10 +43,10 @@ public class QueryWrapper<T> extends AbstractWrapper<T, String, QueryWrapper<T>>
     /**
      * 查询字段
      */
-    private final SharedString sqlSelect = new SharedString();
+    protected final SharedString sqlSelect = new SharedString();
 
     public QueryWrapper() {
-        this(null);
+        this((T) null);
     }
 
     public QueryWrapper(T entity) {
@@ -54,6 +54,11 @@ public class QueryWrapper<T> extends AbstractWrapper<T, String, QueryWrapper<T>>
         super.initNeed();
     }
 
+    public QueryWrapper(Class<T> entityClass) {
+        super.setEntityClass(entityClass);
+        super.initNeed();
+    }
+
     public QueryWrapper(T entity, String... columns) {
         super.setEntity(entity);
         super.initNeed();

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/query/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/AbstractISegmentList.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/ColumnSegment.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/GroupBySegmentList.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/HavingSegmentList.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/MatchSegment.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/MergeSegments.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/NormalSegmentList.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/OrderBySegmentList.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/segments/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 4 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/LambdaUpdateWrapper.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -84,9 +84,9 @@ public class LambdaUpdateWrapper<T> extends AbstractLambdaWrapper<T, LambdaUpdat
     }
 
     @Override
-    public LambdaUpdateWrapper<T> setSql(boolean condition, String sql) {
-        if (condition && StringUtils.isNotBlank(sql)) {
-            sqlSet.add(sql);
+    public LambdaUpdateWrapper<T> setSql(boolean condition, String setSql, Object... params) {
+        if (condition && StringUtils.isNotBlank(setSql)) {
+            sqlSet.add(formatSqlMaybeWithParam(setSql, params));
         }
         return typedThis;
     }

+ 9 - 5
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/Update.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -63,17 +63,21 @@ public interface Update<Children, R> extends Serializable {
     /**
      * ignore
      */
-    default Children setSql(String sql) {
-        return setSql(true, sql);
+    default Children setSql(String setSql, Object... params) {
+        return setSql(true, setSql, params);
     }
 
     /**
      * 设置 更新 SQL 的 SET 片段
      *
-     * @param sql set sql
+     * @param setSql set sql
+     *               例1: setSql("id=1")
+     *               例2: apply("dateColumn={0}", LocalDate.now())
+     *               例3: apply("dateColumn={0}", LocalDate.now())
+     *               例4: apply("name={0,javaType=int,jdbcType=NUMERIC,typeHandler=xxx.xxx.MyTypeHandler}", "老王")
      * @return children
      */
-    Children setSql(boolean condition, String sql);
+    Children setSql(boolean condition, String setSql, Object... params);
 
     /**
      * 获取 更新 SQL 的 SET 片段

+ 4 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/UpdateWrapper.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -84,9 +84,9 @@ public class UpdateWrapper<T> extends AbstractWrapper<T, String, UpdateWrapper<T
     }
 
     @Override
-    public UpdateWrapper<T> setSql(boolean condition, String sql) {
-        if (condition && StringUtils.isNotBlank(sql)) {
-            sqlSet.add(sql);
+    public UpdateWrapper<T> setSql(boolean condition, String setSql, Object... params) {
+        if (condition && StringUtils.isNotBlank(setSql)) {
+            sqlSet.add(formatSqlMaybeWithParam(setSql, params));
         }
         return typedThis;
     }

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/conditions/update/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 13 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/config/GlobalConfig.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -67,7 +67,10 @@ public class GlobalConfig implements Serializable {
     private Class<?> superMapperClass = Mapper.class;
     /**
      * 仅用于缓存 SqlSessionFactory(外部勿进行set,set了也没用)
+     *
+     * @deprecated 3.5.3.2
      */
+    @Deprecated
     private SqlSessionFactory sqlSessionFactory;
     /**
      * 缓存已注入CRUD的Mapper信息
@@ -117,6 +120,15 @@ public class GlobalConfig implements Serializable {
          * @since 3.1.1
          */
         private String columnFormat;
+        /**
+         * db 表 format
+         * <p>
+         * 例: `%s`
+         * <p>
+         *
+         * @since 3.5.3.2
+         */
+        private String tableFormat;
         /**
          * entity 的字段(property)的 format,只有在 column as property 这种情况下生效
          * <p>

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/config/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/enums/SqlKeyword.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/enums/SqlLike.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 6 - 2
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/enums/SqlMethod.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,7 +31,8 @@ public enum SqlMethod {
     /**
      * 删除
      */
-    DELETE_BY_ID("deleteById", "根据ID 删除一条数据", "<script>\nDELETE FROM %s WHERE %s=#{%s}\n</script>"),
+    DELETE_BY_ID("deleteById", "根据ID 删除一条数据", "DELETE FROM %s WHERE %s=#{%s}"),
+    @Deprecated
     DELETE_BY_MAP("deleteByMap", "根据columnMap 条件删除记录", "<script>\nDELETE FROM %s %s\n</script>"),
     DELETE("delete", "根据 entity 条件删除记录", "<script>\nDELETE FROM %s %s %s\n</script>"),
     DELETE_BATCH_BY_IDS("deleteBatchIds", "根据ID集合,批量删除数据", "<script>\nDELETE FROM %s WHERE %s IN (%s)\n</script>"),
@@ -59,14 +60,17 @@ public enum SqlMethod {
      * 查询
      */
     SELECT_BY_ID("selectById", "根据ID 查询一条数据", "SELECT %s FROM %s WHERE %s=#{%s} %s"),
+    @Deprecated
     SELECT_BY_MAP("selectByMap", "根据columnMap 查询一条数据", "<script>SELECT %s FROM %s %s\n</script>"),
     SELECT_BATCH_BY_IDS("selectBatchIds", "根据ID集合,批量查询数据", "<script>SELECT %s FROM %s WHERE %s IN (%s) %s </script>"),
     @Deprecated
     SELECT_ONE("selectOne", "查询满足条件一条数据", "<script>%s SELECT %s FROM %s %s %s\n</script>"),
     SELECT_COUNT("selectCount", "查询满足条件总记录数", "<script>%s SELECT COUNT(%s) AS total FROM %s %s %s\n</script>"),
     SELECT_LIST("selectList", "查询满足条件所有数据", "<script>%s SELECT %s FROM %s %s %s %s\n</script>"),
+    @Deprecated
     SELECT_PAGE("selectPage", "查询满足条件所有数据(并翻页)", "<script>%s SELECT %s FROM %s %s %s %s\n</script>"),
     SELECT_MAPS("selectMaps", "查询满足条件所有数据", "<script>%s SELECT %s FROM %s %s %s %s\n</script>"),
+    @Deprecated
     SELECT_MAPS_PAGE("selectMapsPage", "查询满足条件所有数据(并翻页)", "<script>\n%s SELECT %s FROM %s %s %s %s\n</script>"),
     SELECT_OBJS("selectObjs", "查询满足条件所有数据", "<script>%s SELECT %s FROM %s %s %s %s\n</script>");
 

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/enums/WrapperKeyword.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/enums/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/exceptions/MybatisPlusException.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/exceptions/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 15 - 0
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/AnnotationHandler.java

@@ -1,3 +1,18 @@
+/*
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package com.baomidou.mybatisplus.core.handlers;
 
 import java.lang.annotation.Annotation;

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/CompositeEnumTypeHandler.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/MetaObjectHandler.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 4 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/MybatisEnumTypeHandler.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -116,7 +116,7 @@ public class MybatisEnumTypeHandler<E extends Enum<E>> extends BaseTypeHandler<E
     @Override
     public E getNullableResult(ResultSet rs, String columnName) throws SQLException {
         Object value = rs.getObject(columnName, this.propertyType);
-        if (null == value && rs.wasNull()) {
+        if (null == value || rs.wasNull()) {
             return null;
         }
         return this.valueOf(value);
@@ -125,7 +125,7 @@ public class MybatisEnumTypeHandler<E extends Enum<E>> extends BaseTypeHandler<E
     @Override
     public E getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
         Object value = rs.getObject(columnIndex, this.propertyType);
-        if (null == value && rs.wasNull()) {
+        if (null == value || rs.wasNull()) {
             return null;
         }
         return this.valueOf(value);
@@ -134,7 +134,7 @@ public class MybatisEnumTypeHandler<E extends Enum<E>> extends BaseTypeHandler<E
     @Override
     public E getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
         Object value = cs.getObject(columnIndex, this.propertyType);
-        if (null == value && cs.wasNull()) {
+        if (null == value || cs.wasNull()) {
             return null;
         }
         return this.valueOf(value);

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/PostInitTableInfoHandler.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/StrictFill.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/handlers/package-info.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

+ 18 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/incrementer/DefaultIdentifierGenerator.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,8 +27,14 @@ import java.net.InetAddress;
  * @since 3.3.0
  */
 public class DefaultIdentifierGenerator implements IdentifierGenerator {
+
     private final Sequence sequence;
 
+    /**
+     * @see #getInstance()
+     * @deprecated 3.5.3.2 共享默认单例
+     */
+    @Deprecated
     public DefaultIdentifierGenerator() {
         this.sequence = new Sequence(null);
     }
@@ -49,4 +55,15 @@ public class DefaultIdentifierGenerator implements IdentifierGenerator {
     public Long nextId(Object entity) {
         return sequence.nextId();
     }
+
+    public static DefaultIdentifierGenerator getInstance() {
+        return DefaultInstance.INSTANCE;
+    }
+
+    private static class DefaultInstance {
+
+        public static final DefaultIdentifierGenerator INSTANCE = new DefaultIdentifierGenerator();
+
+    }
+
 }

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/incrementer/IKeyGenerator.java

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2022, baomidou (jobob@qq.com).
+ * Copyright (c) 2011-2023, baomidou (jobob@qq.com).
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

部分文件因文件數量過多而無法顯示