diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java index 979d6c32f40f..f89e0399ae1d 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java @@ -171,26 +171,18 @@ protected TransactionAttribute computeTransactionAttribute(Method method, @Nulla // If the target class is null, the method will be unchanged. Method specificMethod = AopUtils.getMostSpecificMethod(method, targetClass); - // First try is the method in the target class. + // First try is the method in the declaring class. TransactionAttribute txAttr = findTransactionAttribute(specificMethod); if (txAttr != null) { return txAttr; } - // Second try is the transaction attribute on the declaring class. - txAttr = findTransactionAttribute(specificMethod.getDeclaringClass()); + // Second try is the transaction attribute on the target class. + txAttr = findTransactionAttribute(targetClass != null ? targetClass : specificMethod.getDeclaringClass()); if (txAttr != null && ClassUtils.isUserLevelMethod(method)) { return txAttr; } - // Third try is the transaction attribute on the target class. - if (targetClass != null) { - txAttr = findTransactionAttribute(targetClass); - if (txAttr != null && ClassUtils.isUserLevelMethod(method)) { - return txAttr; - } - } - if (specificMethod != method) { // Fallback is to look at the original method. txAttr = findTransactionAttribute(method);