diff --git a/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java b/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java index a91f1a26b..622a6dc4c 100644 --- a/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java +++ b/src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java @@ -61,6 +61,7 @@ import org.springframework.data.repository.util.ReactiveWrapperConverters; import org.springframework.data.repository.util.ReactiveWrappers; import org.springframework.data.util.Pair; import org.springframework.data.util.ReflectionUtils; +import org.springframework.transaction.interceptor.TransactionalProxy; import org.springframework.util.Assert; /** @@ -73,8 +74,6 @@ import org.springframework.util.Assert; */ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware, BeanFactoryAware { - private static final Class TRANSACTION_PROXY_TYPE = getTransactionProxyType(); - private final Map repositoryInformationCache; private final List postProcessors; @@ -230,15 +229,11 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware, // Create proxy ProxyFactory result = new ProxyFactory(); result.setTarget(target); - result.setInterfaces(new Class[] { repositoryInterface, Repository.class }); + result.setInterfaces(new Class[] { repositoryInterface, Repository.class, TransactionalProxy.class }); result.addAdvice(SurroundingTransactionDetectorMethodInterceptor.INSTANCE); result.addAdvisor(ExposeInvocationInterceptor.ADVISOR); - if (TRANSACTION_PROXY_TYPE != null) { - result.addInterface(TRANSACTION_PROXY_TYPE); - } - postProcessors.forEach(processor -> processor.postProcess(result, information)); result.addAdvice(new DefaultMethodInvokingMethodInterceptor()); @@ -376,21 +371,6 @@ public abstract class RepositoryFactorySupport implements BeanClassLoaderAware, }); } - /** - * Returns the TransactionProxy type or {@literal null} if not on the classpath. - * - * @return - */ - private static Class getTransactionProxyType() { - - try { - return org.springframework.util.ClassUtils - .forName("org.springframework.transaction.interceptor.TransactionalProxy", null); - } catch (ClassNotFoundException o_O) { - return null; - } - } - /** * This {@code MethodInterceptor} intercepts calls to methods of the custom implementation and delegates the to it if * configured. Furthermore it resolves method calls to finders and triggers execution of them. You can rely on having diff --git a/src/main/java/org/springframework/data/repository/support/ReflectionRepositoryInvoker.java b/src/main/java/org/springframework/data/repository/support/ReflectionRepositoryInvoker.java index f04c8cca0..a0d8980b4 100644 --- a/src/main/java/org/springframework/data/repository/support/ReflectionRepositoryInvoker.java +++ b/src/main/java/org/springframework/data/repository/support/ReflectionRepositoryInvoker.java @@ -135,7 +135,6 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker { * @see org.springframework.data.rest.core.invoke.RepositoryInvoker#invokeFindOne(java.io.Serializable) */ @Override - @SuppressWarnings("unchecked") public T invokeFindOne(Serializable id) { Method method = methods.getFindOneMethod()//