Skip to content

Commit f002ebd

Browse files
committed
Explicit notes on class/method-level semantics in class hierarchies
Issue: SPR-17445 (cherry picked from commit ea3250c)
1 parent b43e733 commit f002ebd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

spring-tx/src/main/java/org/springframework/transaction/annotation/Transactional.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
import org.springframework.transaction.TransactionDefinition;
2828

2929
/**
30-
* Describes transaction attributes on a method or class.
30+
* Describes a transaction attribute on an individual method or on a class.
31+
*
32+
* <p>At the class level, this annotation applies as a default to all methods of
33+
* the declaring class and its subclasses. Note that it does not apply to ancestor
34+
* classes up the class hierarchy; methods need to be locally redeclared in order
35+
* to participate in a subclass-level annotation.
3136
*
3237
* <p>This annotation type is generally directly comparable to Spring's
3338
* {@link org.springframework.transaction.interceptor.RuleBasedTransactionAttribute}

src/asciidoc/data-access.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,12 @@ following class definition:
10901090
}
10911091
----
10921092

1093+
Used at the class level as above, the annotation indicates a default for all methods
1094+
of the declaring class (as well as its subclasses). Alternatively, each method can
1095+
get annotated individually. Note that a class-level annotation does not apply to
1096+
ancestor classes up the class hierarchy; in such a scenario, methods need to be
1097+
locally redeclared in order to participate in a subclass-level annotation.
1098+
10931099
When the above POJO is defined as a bean in a Spring IoC container, the bean instance
10941100
can be made transactional by adding merely __one__ line of XML configuration:
10951101

@@ -1115,6 +1121,7 @@ can be made transactional by adding merely __one__ line of XML configuration:
11151121
11161122
<!-- enable the configuration of transactional behavior based on annotations -->
11171123
__<tx:annotation-driven transaction-manager="txManager"/>__<!-- a PlatformTransactionManager is still required -->
1124+
11181125
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
11191126
<!-- (this dependency is defined somewhere else) -->
11201127
<property name="dataSource" ref="dataSource"/>

0 commit comments

Comments
 (0)