mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
1.4.13
This commit is contained in:
parent
629101a774
commit
f249368ba7
@ -47,12 +47,12 @@ QQ群:680016987 或者
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
</dependency>
|
||||
```
|
||||
- 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, 再引入以上依赖
|
||||
<br>
|
||||
@ -160,5 +160,5 @@ MPJLambdaWrapper其他功能
|
||||
* <a href="https://yulichang.github.io/mybatis-plus-join-doc/" target="_blank">其他全部功能请参考使用文档</a>
|
||||
|
||||
# <a href="https://yulichang.github.io/mybatis-plus-join-doc" target="_blank">使用文档 wiki</a>
|
||||
# 捐赠
|
||||

|
||||
# 用爱发电
|
||||

|
||||
|
@ -47,12 +47,12 @@ QQ群:680016987 或者
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||
<version>1.4.12</version>
|
||||
<version>1.4.13</version>
|
||||
</dependency>
|
||||
```
|
||||
- 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, 再引入以上依赖
|
||||
<br>
|
||||
@ -160,5 +160,5 @@ MPJLambdaWrapper其他功能
|
||||
* <a href="https://yulichang.github.io/mybatis-plus-join-doc/" target="_blank">其他全部功能请参考使用文档</a>
|
||||
|
||||
# <a href="https://yulichang.github.io/mybatis-plus-join-doc" target="_blank">使用文档 wiki</a>
|
||||
# 捐赠
|
||||

|
||||
# 用爱发电
|
||||

|
||||
|
@ -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<Field> supplier) {
|
||||
return fieldInfo.getField();
|
||||
}
|
||||
|
@ -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<Field> supplier) {
|
||||
return is330 ? supplier.get() : IAdapter.super.mpjGetField(fieldInfo, null);
|
||||
|
@ -30,7 +30,7 @@ public class MPJInterceptorConfig {
|
||||
System.out.println(" _ _ |_ _ _|_. ___ _ | _ . _ . _ \n" +
|
||||
"| | |\\/|_)(_| | |_\\ |_)||_|_\\ | (_) | | | \n" +
|
||||
" / | /\n" +
|
||||
" 1.4.12");
|
||||
" 1.4.13");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
* <p>
|
||||
* Deprecated
|
||||
* 3.5.6 getMethodList(Configuration, Class, TableInfo)
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public List<AbstractMethod> 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<AbstractMethod> 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<AbstractMethod> methodFilter(List<AbstractMethod> list) {
|
||||
String packageStr = SelectList.class.getPackage().getName();
|
||||
List<String> methodList = Arrays.asList(
|
||||
|
@ -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();
|
||||
|
@ -222,10 +222,10 @@ public class DeleteJoinWrapper<T> extends JoinAbstractLambdaWrapper<T, DeleteJoi
|
||||
/**
|
||||
* 不建议直接 new 该实例,使用 JoinWrappers.delete(User.class)
|
||||
*/
|
||||
public DeleteJoinWrapper(T entity, Class<T> entityClass, AtomicInteger paramNameSeq,
|
||||
Map<String, Object> paramNameValuePairs, MergeSegments mergeSegments,
|
||||
SharedString lastSql, SharedString sqlComment, SharedString sqlFirst,
|
||||
TableList tableList, Integer index, String keyWord, Class<?> joinClass, String tableName) {
|
||||
protected DeleteJoinWrapper(T entity, Class<T> entityClass, AtomicInteger paramNameSeq,
|
||||
Map<String, Object> 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;
|
||||
|
@ -99,14 +99,14 @@ public abstract class JoinAbstractLambdaWrapper<T, Children extends JoinAbstract
|
||||
/**
|
||||
* 推荐使用 带 class 的构造方法
|
||||
*/
|
||||
public JoinAbstractLambdaWrapper() {
|
||||
protected JoinAbstractLambdaWrapper() {
|
||||
initNeed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 推荐使用此构造方法
|
||||
*/
|
||||
public JoinAbstractLambdaWrapper(Class<T> clazz) {
|
||||
protected JoinAbstractLambdaWrapper(Class<T> clazz) {
|
||||
initNeed();
|
||||
setEntityClass(clazz);
|
||||
tableList.setRootClass(clazz);
|
||||
@ -117,7 +117,7 @@ public abstract class JoinAbstractLambdaWrapper<T, Children extends JoinAbstract
|
||||
*
|
||||
* @param entity 主表实体
|
||||
*/
|
||||
public JoinAbstractLambdaWrapper(T entity) {
|
||||
protected JoinAbstractLambdaWrapper(T entity) {
|
||||
initNeed();
|
||||
setEntity(entity);
|
||||
if (entity != null) {
|
||||
@ -128,7 +128,7 @@ public abstract class JoinAbstractLambdaWrapper<T, Children extends JoinAbstract
|
||||
/**
|
||||
* 自定义主表别名
|
||||
*/
|
||||
public JoinAbstractLambdaWrapper(String alias) {
|
||||
protected JoinAbstractLambdaWrapper(String alias) {
|
||||
this.alias = alias;
|
||||
initNeed();
|
||||
tableList.setAlias(alias);
|
||||
@ -140,7 +140,7 @@ public abstract class JoinAbstractLambdaWrapper<T, Children extends JoinAbstract
|
||||
* @param clazz 主表class类
|
||||
* @param alias 主表别名
|
||||
*/
|
||||
public JoinAbstractLambdaWrapper(Class<T> clazz, String alias) {
|
||||
protected JoinAbstractLambdaWrapper(Class<T> clazz, String alias) {
|
||||
this.alias = alias;
|
||||
setEntityClass(clazz);
|
||||
initNeed();
|
||||
@ -154,7 +154,7 @@ public abstract class JoinAbstractLambdaWrapper<T, Children extends JoinAbstract
|
||||
* @param entity 主表实体类
|
||||
* @param alias 主表别名
|
||||
*/
|
||||
public JoinAbstractLambdaWrapper(T entity, String alias) {
|
||||
protected JoinAbstractLambdaWrapper(T entity, String alias) {
|
||||
this.alias = alias;
|
||||
setEntity(entity);
|
||||
initNeed();
|
||||
|
@ -122,7 +122,7 @@ public class MPJLambdaWrapper<T> extends JoinAbstractLambdaWrapper<T, MPJLambdaW
|
||||
/**
|
||||
* 不建议直接 new 该实例,使用 JoinWrappers.lambda(UserDO.class)
|
||||
*/
|
||||
MPJLambdaWrapper(T entity, Class<T> entityClass, SharedString sqlSelect, AtomicInteger paramNameSeq,
|
||||
protected MPJLambdaWrapper(T entity, Class<T> entityClass, SharedString sqlSelect, AtomicInteger paramNameSeq,
|
||||
Map<String, Object> paramNameValuePairs, MergeSegments mergeSegments, SharedString paramAlias,
|
||||
SharedString lastSql, SharedString sqlComment, SharedString sqlFirst,
|
||||
TableList tableList, Integer index, String keyWord, Class<?> joinClass, String tableName,
|
||||
|
@ -222,7 +222,7 @@ public class UpdateJoinWrapper<T> extends JoinAbstractLambdaWrapper<T, UpdateJoi
|
||||
/**
|
||||
* 不建议直接 new 该实例,使用 JoinWrappers.update(User.class)
|
||||
*/
|
||||
public UpdateJoinWrapper(T entity, Class<T> entityClass, AtomicInteger paramNameSeq,
|
||||
protected UpdateJoinWrapper(T entity, Class<T> entityClass, AtomicInteger paramNameSeq,
|
||||
Map<String, Object> paramNameValuePairs, MergeSegments mergeSegments,
|
||||
SharedString lastSql, SharedString sqlComment, SharedString sqlFirst,
|
||||
TableList tableList, Integer index, String keyWord, Class<?> joinClass, String tableName) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<revision>1.4.12</revision>
|
||||
<revision>1.4.13</revision>
|
||||
<mpj.mybatis.plus.version>3.5.6</mpj.mybatis.plus.version>
|
||||
|
||||
<jdkVersion>1.8</jdkVersion>
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.github.yulichang.test.join.mapper.UserMapper">
|
||||
|
||||
|
||||
</mapper>
|
@ -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 {
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
<artifactId>test-springboot3-jdk17</artifactId>
|
||||
|
||||
<properties>
|
||||
<revision>1.4.12</revision>
|
||||
<revision>1.4.13</revision>
|
||||
<mpj.mybatis.plus.version>3.5.6</mpj.mybatis.plus.version>
|
||||
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
|
@ -41,7 +41,7 @@
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<revision>1.4.12</revision>
|
||||
<revision>1.4.13</revision>
|
||||
|
||||
<jdkVersion>1.8</jdkVersion>
|
||||
<jdkVersion.test>1.8</jdkVersion.test>
|
||||
|
6
pom.xml
6
pom.xml
@ -40,7 +40,7 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<revision>1.4.12</revision>
|
||||
<revision>1.4.13</revision>
|
||||
<mpj.mybatis.plus.version>3.5.6</mpj.mybatis.plus.version>
|
||||
|
||||
<jdkVersion>1.8</jdkVersion>
|
||||
@ -56,13 +56,13 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
<version>1.18.32</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aop</artifactId>
|
||||
<version>5.3.32</version>
|
||||
<version>5.3.36</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
Loading…
x
Reference in New Issue
Block a user