[ACCEPTED]-Does Spring @transaction work on a concrete method of abstract class-spring-transactions

Accepted answer
Score: 20

Granting that you have actually configured 25 Spring transaction management correctly, using 24 @Transactional on an abstract superclass will work, since 23 @Transactional is itself annotated with @Inherited and from it's 22 Javadoc we have:

Indicates that an annotation type 21 is automatically inherited. If an Inherited 20 meta-annotation is present on an annotation 19 type declaration, and the user queries 18 the annotation type on a class declaration, and 17 the class declaration has no annotation 16 for this type, then the class's superclass 15 will automatically be queried for the 14 annotation type. This process will be repeated 13 until an annotation for this type is found, or 12 the top of the class hierarchy (Object) is reached. If 11 no superclass has an annotation for this 10 type, then the query will indicate that 9 the class in question has no such annotation.

Note 8 that this meta-annotation type has no effect 7 if the annotated type is used to annotate 6 anything other than a class. Note also that this 5 meta-annotation only causes annotations 4 to be inherited from superclasses; annotations 3 on implemented interfaces have no effect.

To 2 actually see that @Transactional is annotated with @Inherited check 1 out it's Javadoc

More Related questions