|
@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
|
|
import com.baomidou.mybatisplus.core.handlers.IJsonTypeHandler;
|
|
import com.baomidou.mybatisplus.core.handlers.IJsonTypeHandler;
|
|
import com.baomidou.mybatisplus.core.metadata.MapperProxyMetadata;
|
|
import com.baomidou.mybatisplus.core.metadata.MapperProxyMetadata;
|
|
import com.baomidou.mybatisplus.core.override.MybatisMapperProxy;
|
|
import com.baomidou.mybatisplus.core.override.MybatisMapperProxy;
|
|
|
|
+import com.baomidou.mybatisplus.core.spi.CompatibleHelper;
|
|
import lombok.experimental.UtilityClass;
|
|
import lombok.experimental.UtilityClass;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.ibatis.reflection.MetaObject;
|
|
import org.apache.ibatis.reflection.MetaObject;
|
|
@@ -30,7 +31,6 @@ import org.apache.ibatis.session.SqlSessionFactory;
|
|
import org.apache.ibatis.session.defaults.DefaultSqlSession;
|
|
import org.apache.ibatis.session.defaults.DefaultSqlSession;
|
|
import org.apache.ibatis.type.TypeException;
|
|
import org.apache.ibatis.type.TypeException;
|
|
import org.apache.ibatis.type.TypeHandler;
|
|
import org.apache.ibatis.type.TypeHandler;
|
|
-import org.springframework.aop.framework.AopProxyUtils;
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Proxy;
|
|
import java.lang.reflect.Proxy;
|
|
@@ -119,21 +119,7 @@ public class MybatisUtils {
|
|
* @since 3.5.7
|
|
* @since 3.5.7
|
|
*/
|
|
*/
|
|
public static MybatisMapperProxy<?> getMybatisMapperProxy(Object mapper) {
|
|
public static MybatisMapperProxy<?> getMybatisMapperProxy(Object mapper) {
|
|
- if (mapper instanceof MybatisMapperProxy) {
|
|
|
|
- // fast return
|
|
|
|
- return (MybatisMapperProxy<?>) mapper;
|
|
|
|
- }
|
|
|
|
- Object result = mapper;
|
|
|
|
- if (AopUtils.isLoadSpringAop()) {
|
|
|
|
- while (org.springframework.aop.support.AopUtils.isAopProxy(result)) {
|
|
|
|
- result = AopProxyUtils.getSingletonTarget(result);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (result != null) {
|
|
|
|
- while (Proxy.isProxyClass(result.getClass())) {
|
|
|
|
- result = Proxy.getInvocationHandler(result);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ Object result = extractMapperProxy(mapper);
|
|
if (result instanceof MybatisMapperProxy) {
|
|
if (result instanceof MybatisMapperProxy) {
|
|
return (MybatisMapperProxy<?>) result;
|
|
return (MybatisMapperProxy<?>) result;
|
|
}
|
|
}
|
|
@@ -153,9 +139,10 @@ public class MybatisUtils {
|
|
return mapper;
|
|
return mapper;
|
|
}
|
|
}
|
|
Object result = mapper;
|
|
Object result = mapper;
|
|
- if (AopUtils.isLoadSpringAop()) {
|
|
|
|
- while (org.springframework.aop.support.AopUtils.isAopProxy(result)) {
|
|
|
|
- result = AopProxyUtils.getSingletonTarget(result);
|
|
|
|
|
|
+ if (CompatibleHelper.hasCompatibleSet()) {
|
|
|
|
+ Object proxyTargetObject = CompatibleHelper.getCompatibleSet().getProxyTargetObject(result);
|
|
|
|
+ if (proxyTargetObject != null) {
|
|
|
|
+ result = proxyTargetObject;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (result != null) {
|
|
if (result != null) {
|