Doc: Inheritance of @Transactional and lookup behaviour of AbstractFallbackTransactionAttributeSource [SPR-12474] #17080
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: bulk-closed
An outdated, unresolved issue that's closed in bulk as part of a cleaning process
Ravi Sanwal opened SPR-12474 and commented
Lets start with a question to the expert.
Consider a service(or repo) bean
And a subclass of it
Notice that only one method of ServiceBean is marked
@Transactional
while MagicalServiceBean has a class level@Transactional
declaration.What should be the transactional nature of method serviceMethodB when it is called on an injected (and proxied et al.) instance of MagicalServiceBean?
Apparently as per the apidocs of org.springframework.transaction.interceptor.AnnotationTransactionAttributeSource (org.springframework.transaction.interceptor.AbstractFallbackTransactionAttributeSource) we expect to get a transactional serviceMethodB.
A specific distinction is mentioned between target class and declaring class/interface
Codewise if we look at org.springframework.transaction.interceptor.AbstractFallbackTransactionAttributeSource.getTransactionAttribute(Method, Class<?>), the targetClass parameter points to MagicalServiceBean.class.
You may consider it as a documentation defect.
There could be arguments for both "should apply transactional on extended method"(because this seems more intuitive and correct) and "should not apply on extended method"(to keep it the way base class has defined and because we can always create a delegate method on the extended class if we need to make it transactional)
Regardless this seems to be an odd behavior to me.
Affects: 4.1.2
The text was updated successfully, but these errors were encountered: