|
|
|
@ -8,7 +8,7 @@ danger of undue coupling, because code that is meant to be used transactionally |
|
|
|
almost always deployed that way anyway. |
|
|
|
almost always deployed that way anyway. |
|
|
|
|
|
|
|
|
|
|
|
NOTE: The standard `jakarta.transaction.Transactional` annotation is also supported as |
|
|
|
NOTE: The standard `jakarta.transaction.Transactional` annotation is also supported as |
|
|
|
a drop-in replacement to Spring's own annotation. Please refer to the JTA documentation |
|
|
|
a drop-in replacement for Spring's own annotation. Please refer to the JTA documentation |
|
|
|
for more details. |
|
|
|
for more details. |
|
|
|
|
|
|
|
|
|
|
|
The ease-of-use afforded by the use of the `@Transactional` annotation is best |
|
|
|
The ease-of-use afforded by the use of the `@Transactional` annotation is best |
|
|
|
@ -89,7 +89,7 @@ annotation in a `@Configuration` class. See the |
|
|
|
{spring-framework-api}/transaction/annotation/EnableTransactionManagement.html[javadoc] |
|
|
|
{spring-framework-api}/transaction/annotation/EnableTransactionManagement.html[javadoc] |
|
|
|
for full details. |
|
|
|
for full details. |
|
|
|
|
|
|
|
|
|
|
|
The following example show the configuration needed to enable annotation-driven transaction management: |
|
|
|
The following example shows the configuration needed to enable annotation-driven transaction management: |
|
|
|
|
|
|
|
|
|
|
|
include-code::./AppConfig[tag=snippet,indent=0] |
|
|
|
include-code::./AppConfig[tag=snippet,indent=0] |
|
|
|
|
|
|
|
|
|
|
|
@ -203,8 +203,10 @@ on an interface, a class definition, or a method on a class. However, the mere p |
|
|
|
of the `@Transactional` annotation is not enough to activate the transactional behavior. |
|
|
|
of the `@Transactional` annotation is not enough to activate the transactional behavior. |
|
|
|
The `@Transactional` annotation is merely metadata that can be consumed by corresponding |
|
|
|
The `@Transactional` annotation is merely metadata that can be consumed by corresponding |
|
|
|
runtime infrastructure which uses that metadata to configure the appropriate beans with |
|
|
|
runtime infrastructure which uses that metadata to configure the appropriate beans with |
|
|
|
transactional behavior. In the preceding example, the `<tx:annotation-driven/>` element |
|
|
|
transactional behavior. In the preceding examples that use programmatic configuration, |
|
|
|
switches on actual transaction management at runtime. |
|
|
|
the `@EnableTransactionManagement` annotation switches on actual transaction management |
|
|
|
|
|
|
|
at runtime. Whereas, in the preceding example that uses XML configuration, the |
|
|
|
|
|
|
|
`<tx:annotation-driven/>` element switches on actual transaction management at runtime. |
|
|
|
|
|
|
|
|
|
|
|
TIP: The Spring team recommends that you annotate methods of concrete classes with the |
|
|
|
TIP: The Spring team recommends that you annotate methods of concrete classes with the |
|
|
|
`@Transactional` annotation, rather than relying on annotated methods in interfaces, |
|
|
|
`@Transactional` annotation, rather than relying on annotated methods in interfaces, |
|
|
|
|