Annotation Interface Transactional


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Inherited @Documented public @interface Transactional
Describes a transaction attribute on an individual method or on a class.

When this annotation is declared at the class level, it applies as a default to all methods of the declaring class and its subclasses. Note that it does not apply to ancestor classes up the class hierarchy; inherited methods need to be locally redeclared in order to participate in a subclass-level annotation. For details on method visibility constraints, consult the Transaction Management section of the reference manual.

This annotation type is generally directly comparable to Spring's RuleBasedTransactionAttribute class, and in fact AnnotationTransactionAttributeSource will directly convert the data to the latter class, so that Spring's transaction support code does not have to know about annotations. If no custom rollback rules apply, the transaction will roll back on RuntimeException and Error but not on checked exceptions.

For specific information about the semantics of this annotation's attributes, consult the TransactionDefinition and TransactionAttribute javadocs.

This annotation commonly works with thread-bound transactions managed by a PlatformTransactionManager, exposing a transaction to all data access operations within the current execution thread. Note: This does NOT propagate to newly started threads within the method.

Alternatively, this annotation may demarcate a reactive transaction managed by a ReactiveTransactionManager which uses the Reactor context instead of thread-local variables. As a consequence, all participating data access operations need to execute within the same Reactor context in the same reactive pipeline.

Since:
1.2
Author:
Colin Sampaleanu, Juergen Hoeller, Sam Brannen, Mark Paluch
See Also: