diff --git a/README-zh.md b/README-zh.md index 275ffe7..0370cf4 100644 --- a/README-zh.md +++ b/README-zh.md @@ -47,12 +47,12 @@ QQ群:680016987 或者 com.github.yulichang mybatis-plus-join-boot-starter - 1.4.12 + 1.4.13 ``` - Gradle ``` - implementation 'com.github.yulichang:mybatis-plus-join-boot-starter:1.4.12' + implementation 'com.github.yulichang:mybatis-plus-join-boot-starter:1.4.13' ``` 或者clone代码到本地执行 mvn install, 再引入以上依赖
@@ -160,5 +160,5 @@ MPJLambdaWrapper其他功能 * 其他全部功能请参考使用文档 # 使用文档 wiki -# 捐赠 -![捐赠 mybatis-plus-join](https://foruda.gitee.com/images/1715967492739259773/c8f375b5_2020985.png "支持一下mybatis-plus-join") +# 用爱发电 +![捐赠 mybatis-plus-join](https://foruda.gitee.com/images/1717191488951888381/8463cfcd_2020985.png "支持一下mybatis-plus-join") diff --git a/README.md b/README.md index 6a74452..2e4b335 100644 --- a/README.md +++ b/README.md @@ -47,12 +47,12 @@ QQ群:680016987 或者 com.github.yulichang mybatis-plus-join-boot-starter - 1.4.12 + 1.4.13 ``` - Gradle ``` - implementation 'com.github.yulichang:mybatis-plus-join-boot-starter:1.4.12' + implementation 'com.github.yulichang:mybatis-plus-join-boot-starter:1.4.13' ``` 或者clone代码到本地执行 mvn install, 再引入以上依赖
@@ -160,5 +160,5 @@ MPJLambdaWrapper其他功能 * 其他全部功能请参考使用文档 # 使用文档 wiki -# 捐赠 -![捐赠 mybatis-plus-join](https://foruda.gitee.com/images/1715967492739259773/c8f375b5_2020985.png "支持一下mybatis-plus-join") +# 用爱发电 +![捐赠 mybatis-plus-join](https://foruda.gitee.com/images/1717191488951888381/8463cfcd_2020985.png "支持一下mybatis-plus-join") diff --git a/mybatis-plus-join-adapter/mybatis-plus-join-adapter-base/src/main/java/com/github/yulichang/adapter/base/IAdapter.java b/mybatis-plus-join-adapter/mybatis-plus-join-adapter-base/src/main/java/com/github/yulichang/adapter/base/IAdapter.java index 72e35c6..8dfc949 100644 --- a/mybatis-plus-join-adapter/mybatis-plus-join-adapter-base/src/main/java/com/github/yulichang/adapter/base/IAdapter.java +++ b/mybatis-plus-join-adapter/mybatis-plus-join-adapter-base/src/main/java/com/github/yulichang/adapter/base/IAdapter.java @@ -3,6 +3,7 @@ package com.github.yulichang.adapter.base; import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; import com.baomidou.mybatisplus.core.metadata.TableInfo; import com.github.yulichang.adapter.base.metadata.OrderFieldInfo; +import org.apache.ibatis.session.Configuration; import java.lang.reflect.Field; import java.util.List; @@ -36,6 +37,10 @@ public interface IAdapter { return tableInfo.havePK(); } + default Configuration mpjGetConfiguration(TableInfo tableInfo) { + return tableInfo.getConfiguration(); + } + default Field mpjGetField(TableFieldInfo fieldInfo, Supplier supplier) { return fieldInfo.getField(); } diff --git a/mybatis-plus-join-adapter/mybatis-plus-join-adapter-v33x/src/main/java/com/github/yulichang/adapter/v33x/AdapterV33x.java b/mybatis-plus-join-adapter/mybatis-plus-join-adapter-v33x/src/main/java/com/github/yulichang/adapter/v33x/AdapterV33x.java index 972fe7e..ce87259 100644 --- a/mybatis-plus-join-adapter/mybatis-plus-join-adapter-v33x/src/main/java/com/github/yulichang/adapter/v33x/AdapterV33x.java +++ b/mybatis-plus-join-adapter/mybatis-plus-join-adapter-v33x/src/main/java/com/github/yulichang/adapter/v33x/AdapterV33x.java @@ -9,6 +9,7 @@ import com.github.yulichang.adapter.base.IAdapter; import com.github.yulichang.adapter.base.metadata.OrderFieldInfo; import com.github.yulichang.adapter.base.tookit.VersionUtils; import com.github.yulichang.adapter.jsqlparser.v46.JSqlParserHelperV46; +import org.apache.ibatis.session.Configuration; import java.lang.reflect.Field; import java.util.List; @@ -55,6 +56,11 @@ public class AdapterV33x implements IAdapter { StringUtils.isNotBlank(tableInfo.getKeyColumn()); } + @Override + public Configuration mpjGetConfiguration(TableInfo tableInfo) { + return tableInfo.getConfiguration(); + } + @Override public Field mpjGetField(TableFieldInfo fieldInfo, Supplier supplier) { return is330 ? supplier.get() : IAdapter.super.mpjGetField(fieldInfo, null); diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MPJInterceptorConfig.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MPJInterceptorConfig.java index 2cf4731..4d357d3 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MPJInterceptorConfig.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/config/MPJInterceptorConfig.java @@ -30,7 +30,7 @@ public class MPJInterceptorConfig { System.out.println(" _ _ |_ _ _|_. ___ _ | _ . _ . _ \n" + "| | |\\/|_)(_| | |_\\ |_)||_|_\\ | (_) | | | \n" + " / | /\n" + - " 1.4.12"); + " 1.4.13"); } } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/injector/MPJSqlInjector.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/injector/MPJSqlInjector.java index 1b54db1..504b390 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/injector/MPJSqlInjector.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/injector/MPJSqlInjector.java @@ -19,6 +19,7 @@ import com.github.yulichang.toolkit.TableHelper; import com.github.yulichang.toolkit.reflect.GenericTypeUtils; import lombok.Getter; import org.apache.ibatis.builder.MapperBuilderAssistant; +import org.apache.ibatis.session.Configuration; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; @@ -85,8 +86,12 @@ public class MPJSqlInjector extends DefaultSqlInjector { /** * mybatis plus 3.4.3.2 + *

+ * Deprecated + * 3.5.6 getMethodList(Configuration, Class, TableInfo) */ @Override + @Deprecated public List getMethodList(Class mapperClass, TableInfo tableInfo) { if (Objects.nonNull(sqlInjector)) { return methodFilter(sqlInjector.getMethodList(mapperClass, tableInfo)); @@ -94,6 +99,14 @@ public class MPJSqlInjector extends DefaultSqlInjector { return methodFilter(super.getMethodList(mapperClass, tableInfo)); } + @Override + public List getMethodList(Configuration configuration, Class mapperClass, TableInfo tableInfo) { + if (Objects.nonNull(sqlInjector)) { + return methodFilter(sqlInjector.getMethodList(configuration, mapperClass, tableInfo)); + } + return methodFilter(super.getMethodList(configuration, mapperClass, tableInfo)); + } + private List methodFilter(List list) { String packageStr = SelectList.class.getPackage().getName(); List methodList = Arrays.asList( diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/method/mp/TableAlias.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/method/mp/TableAlias.java index b7b0ed0..0e673b9 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/method/mp/TableAlias.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/method/mp/TableAlias.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.TableInfo; import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.core.toolkit.ExceptionUtils; import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils; +import com.github.yulichang.adapter.AdapterHelper; import com.github.yulichang.interfaces.MPJBaseJoin; import com.github.yulichang.method.MPJBaseMethod; import org.apache.ibatis.session.Configuration; @@ -39,7 +40,8 @@ public interface TableAlias extends Constants, MPJBaseMethod { try { table = TableInfo.class.getDeclaredConstructor(Class.class).newInstance(tableInfo.getEntityType()); } catch (Exception e) { - table = TableInfo.class.getDeclaredConstructor(Configuration.class, Class.class).newInstance(tableInfo.getConfiguration(), tableInfo.getEntityType()); + table = TableInfo.class.getDeclaredConstructor(Configuration.class, Class.class).newInstance( + AdapterHelper.getAdapter().mpjGetConfiguration(tableInfo), tableInfo.getEntityType()); } //反射拷贝对象 Field[] fields = TableInfo.class.getDeclaredFields(); diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/DeleteJoinWrapper.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/DeleteJoinWrapper.java index 3eb7da4..f2c3e62 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/DeleteJoinWrapper.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/DeleteJoinWrapper.java @@ -222,10 +222,10 @@ public class DeleteJoinWrapper extends JoinAbstractLambdaWrapper entityClass, AtomicInteger paramNameSeq, - Map paramNameValuePairs, MergeSegments mergeSegments, - SharedString lastSql, SharedString sqlComment, SharedString sqlFirst, - TableList tableList, Integer index, String keyWord, Class joinClass, String tableName) { + protected DeleteJoinWrapper(T entity, Class entityClass, AtomicInteger paramNameSeq, + Map paramNameValuePairs, MergeSegments mergeSegments, + SharedString lastSql, SharedString sqlComment, SharedString sqlFirst, + TableList tableList, Integer index, String keyWord, Class joinClass, String tableName) { super.setEntity(entity); super.setEntityClass(entityClass); this.paramNameSeq = paramNameSeq; diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/JoinAbstractLambdaWrapper.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/JoinAbstractLambdaWrapper.java index d56ffbd..2a72db2 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/JoinAbstractLambdaWrapper.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/JoinAbstractLambdaWrapper.java @@ -99,14 +99,14 @@ public abstract class JoinAbstractLambdaWrapper clazz) { + protected JoinAbstractLambdaWrapper(Class clazz) { initNeed(); setEntityClass(clazz); tableList.setRootClass(clazz); @@ -117,7 +117,7 @@ public abstract class JoinAbstractLambdaWrapper clazz, String alias) { + protected JoinAbstractLambdaWrapper(Class clazz, String alias) { this.alias = alias; setEntityClass(clazz); initNeed(); @@ -154,7 +154,7 @@ public abstract class JoinAbstractLambdaWrapper extends JoinAbstractLambdaWrapper entityClass, SharedString sqlSelect, AtomicInteger paramNameSeq, + protected MPJLambdaWrapper(T entity, Class entityClass, SharedString sqlSelect, AtomicInteger paramNameSeq, Map paramNameValuePairs, MergeSegments mergeSegments, SharedString paramAlias, SharedString lastSql, SharedString sqlComment, SharedString sqlFirst, TableList tableList, Integer index, String keyWord, Class joinClass, String tableName, diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/UpdateJoinWrapper.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/UpdateJoinWrapper.java index 3f6018e..cfc69b4 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/UpdateJoinWrapper.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/UpdateJoinWrapper.java @@ -222,7 +222,7 @@ public class UpdateJoinWrapper extends JoinAbstractLambdaWrapper entityClass, AtomicInteger paramNameSeq, + protected UpdateJoinWrapper(T entity, Class entityClass, AtomicInteger paramNameSeq, Map paramNameValuePairs, MergeSegments mergeSegments, SharedString lastSql, SharedString sqlComment, SharedString sqlFirst, TableList tableList, Integer index, String keyWord, Class joinClass, String tableName) { diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectCache.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectCache.java index 54c6157..989f868 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectCache.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectCache.java @@ -3,6 +3,7 @@ package com.github.yulichang.wrapper.segments; import com.baomidou.mybatisplus.core.metadata.TableFieldInfo; import com.baomidou.mybatisplus.core.metadata.TableInfo; import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.github.yulichang.adapter.AdapterHelper; import com.github.yulichang.toolkit.MPJStringUtils; import com.github.yulichang.toolkit.TableHelper; import lombok.Getter; @@ -84,7 +85,7 @@ public class SelectCache { this.hasTypeHandle = this.tableFieldInfo.getTypeHandler() != null && tableFieldInfo.getTypeHandler() != UnknownTypeHandler.class; if (this.hasTypeHandle) { TableInfo info = TableHelper.getAssert(clazz); - this.typeHandler = getTypeHandler(info.getConfiguration(), tableFieldInfo); + this.typeHandler = getTypeHandler(AdapterHelper.getAdapter().mpjGetConfiguration(info), tableFieldInfo); } else { this.typeHandler = null; } diff --git a/mybatis-plus-join-test/pom.xml b/mybatis-plus-join-test/pom.xml index 94dff8c..b00adfb 100644 --- a/mybatis-plus-join-test/pom.xml +++ b/mybatis-plus-join-test/pom.xml @@ -50,7 +50,7 @@ - 1.4.12 + 1.4.13 3.5.6 1.8 diff --git a/mybatis-plus-join-test/test-base/src/main/java/com/github/yulichang/test/util/EnabledIf.java b/mybatis-plus-join-test/test-base/src/main/java/com/github/yulichang/test/util/EnabledIf.java index bfddbbf..2c00885 100644 --- a/mybatis-plus-join-test/test-base/src/main/java/com/github/yulichang/test/util/EnabledIf.java +++ b/mybatis-plus-join-test/test-base/src/main/java/com/github/yulichang/test/util/EnabledIf.java @@ -9,6 +9,10 @@ public class EnabledIf { return DbTypeUtil.getDbType() == DbType.MYSQL; } + public static boolean runWithPgsql() { + return DbTypeUtil.getDbType() == DbType.POSTGRE_SQL; + } + public static boolean runWithExcludingOracle() { return DbTypeUtil.getDbType() != DbType.ORACLE; } diff --git a/mybatis-plus-join-test/test-join/src/main/resources/mapper/UserMapper.xml b/mybatis-plus-join-test/test-join/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000..90efe33 --- /dev/null +++ b/mybatis-plus-join-test/test-join/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/DeleteJoinTest.java b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/DeleteJoinTest.java index 1953dc2..d0462a3 100644 --- a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/DeleteJoinTest.java +++ b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/DeleteJoinTest.java @@ -17,7 +17,7 @@ import org.springframework.boot.test.context.SpringBootTest; * 连表删除没有同意语法语法,不同数据库差别较大 * MPJ 连表更新 目前只支持 mysql */ -@SpringBootTest +@SpringBootTest("spring.profiles.active=mysql") @EnabledIf("com.github.yulichang.test.util.EnabledIf#runWithMysql") public class DeleteJoinTest { diff --git a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/MysqlTest.java b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/MysqlTest.java index 62c6b4c..aa891f3 100644 --- a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/MysqlTest.java +++ b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/MysqlTest.java @@ -17,7 +17,7 @@ import org.springframework.boot.test.context.SpringBootTest; * 由于不同数据库函数支持情况不同 * 此类用于测试 mysql 专属语法或函数 */ -@SpringBootTest +@SpringBootTest("spring.profiles.active=mysql") @EnabledIf("com.github.yulichang.test.util.EnabledIf#runWithMysql") public class MysqlTest { diff --git a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/UpdateJoinTest.java b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/UpdateJoinTest.java index 3901428..6a720c2 100644 --- a/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/UpdateJoinTest.java +++ b/mybatis-plus-join-test/test-join/src/test/java/com/github/yulichang/test/join/mysql/UpdateJoinTest.java @@ -23,7 +23,7 @@ import java.util.List; * 连表更新没有同意语法语法,不同数据库差别较大 * MPJ 连表更新 目前只支持 mysql */ -@SpringBootTest +@SpringBootTest("spring.profiles.active=mysql") @EnabledIf("com.github.yulichang.test.util.EnabledIf#runWithMysql") public class UpdateJoinTest { diff --git a/mybatis-plus-join-test/test-springboot3-jdk17/pom.xml b/mybatis-plus-join-test/test-springboot3-jdk17/pom.xml index 0364d8d..7e38df4 100644 --- a/mybatis-plus-join-test/test-springboot3-jdk17/pom.xml +++ b/mybatis-plus-join-test/test-springboot3-jdk17/pom.xml @@ -14,7 +14,7 @@ test-springboot3-jdk17 - 1.4.12 + 1.4.13 3.5.6 17 diff --git a/mybatis-plus-join/pom.xml b/mybatis-plus-join/pom.xml index c9bb68d..b6f4c52 100644 --- a/mybatis-plus-join/pom.xml +++ b/mybatis-plus-join/pom.xml @@ -41,7 +41,7 @@ - 1.4.12 + 1.4.13 1.8 1.8 diff --git a/pom.xml b/pom.xml index 8eab3fb..60487bd 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ - 1.4.12 + 1.4.13 3.5.6 1.8 @@ -56,13 +56,13 @@ org.projectlombok lombok - 1.18.30 + 1.18.32 provided org.springframework spring-aop - 5.3.32 + 5.3.36 provided