Transactional
directly or switch to Micronaut Data's TransactionalAdvice
@Target(value={METHOD,TYPE}) @Retention(value=RUNTIME) @Inherited @Documented @Around @Type(value=TransactionInterceptor.class) @Deprecated public @interface Transactional
Transactional
that uses Micronaut AOP
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 rules are relevant to the exception,
it will be treated like
DefaultTransactionAttribute
(rolling 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.
TransactionAttribute
,
DefaultTransactionAttribute
,
RuleBasedTransactionAttribute
Modifier and Type | Optional Element and Description |
---|---|
org.springframework.transaction.annotation.Isolation |
isolation
Deprecated.
The transaction isolation level.
|
java.lang.Class<? extends java.lang.Throwable>[] |
noRollbackFor
Deprecated.
Defines zero (0) or more exception
Classes , which must be
subclasses of Throwable , indicating which exception types must
not cause a transaction rollback. |
java.lang.String[] |
noRollbackForClassName
Deprecated.
Defines zero (0) or more exception names (for exceptions which must be a
subclass of
Throwable ) indicating which exception types must not
cause a transaction rollback. |
org.springframework.transaction.annotation.Propagation |
propagation
Deprecated.
The transaction propagation type.
|
boolean |
readOnly
Deprecated.
true if the transaction is read-only. |
java.lang.Class<? extends java.lang.Throwable>[] |
rollbackFor
Deprecated.
Defines zero (0) or more exception
classes , which must be
subclasses of Throwable , indicating which exception types must cause
a transaction rollback. |
java.lang.String[] |
rollbackForClassName
Deprecated.
Defines zero (0) or more exception names (for exceptions which must be a
subclass of
Throwable ), indicating which exception types must cause
a transaction rollback. |
int |
timeout
Deprecated.
The timeout for this transaction.
|
java.lang.String |
transactionManager
Deprecated.
A qualifier value for the specified transaction.
|
java.lang.String |
value
Deprecated.
Alias for
transactionManager() . |
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class, member="transactionManager") public abstract java.lang.String value
transactionManager()
.transactionManager()
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class, member="value") public abstract java.lang.String transactionManager
May be used to determine the target transaction manager,
matching the qualifier value (or the bean name) of a specific
PlatformTransactionManager
bean definition.
value()
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class, member="propagation") public abstract org.springframework.transaction.annotation.Propagation propagation
Defaults to Propagation.REQUIRED
.
TransactionDefinition.getPropagationBehavior()
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class, member="isolation") public abstract org.springframework.transaction.annotation.Isolation isolation
Defaults to Isolation.DEFAULT
.
TransactionDefinition.getIsolationLevel()
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class, member="timeout") public abstract int timeout
Defaults to the default timeout of the underlying transaction system.
TransactionDefinition.getTimeout()
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class, member="readOnly") public abstract boolean readOnly
true
if the transaction is read-only.
Defaults to false
.
This just serves as a hint for the actual transaction subsystem; it will not necessarily cause failure of write access attempts. A transaction manager which cannot interpret the read-only hint will not throw an exception when asked for a read-only transaction but rather silently ignore the hint.
TransactionDefinition.isReadOnly()
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class, member="rollbackFor") public abstract java.lang.Class<? extends java.lang.Throwable>[] rollbackFor
classes
, which must be
subclasses of Throwable
, indicating which exception types must cause
a transaction rollback.
By default, a transaction will be rolling back on RuntimeException
and Error
but not on checked exceptions (business exceptions). See
DefaultTransactionAttribute.rollbackOn(Throwable)
for a detailed explanation.
This is the preferred way to construct a rollback rule (in contrast to
rollbackForClassName()
), matching the exception class and its subclasses.
Similar to RollbackRuleAttribute(Class clazz)
.
rollbackForClassName()
,
DefaultTransactionAttribute.rollbackOn(Throwable)
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class, member="rollbackForClassName") public abstract java.lang.String[] rollbackForClassName
Throwable
), indicating which exception types must cause
a transaction rollback.
This can be a substring of a fully qualified class name, with no wildcard
support at present. For example, a value of "ServletException"
would
match javax.servlet.ServletException
and its subclasses.
NB: Consider carefully how specific the pattern is and whether
to include package information (which isn't mandatory). For example,
"Exception"
will match nearly anything and will probably hide other
rules. "java.lang.Exception"
would be correct if "Exception"
were meant to define a rule for all checked exceptions. With more unusual
Exception
names such as "BaseBusinessException"
there is no
need to use a FQN.
Similar to RollbackRuleAttribute(String exceptionName)
.
rollbackFor()
,
DefaultTransactionAttribute.rollbackOn(Throwable)
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class, member="rollbackOn") public abstract java.lang.Class<? extends java.lang.Throwable>[] noRollbackFor
Classes
, which must be
subclasses of Throwable
, indicating which exception types must
not cause a transaction rollback.
This is the preferred way to construct a rollback rule (in contrast
to noRollbackForClassName()
), matching the exception class and
its subclasses.
Similar to NoRollbackRuleAttribute(Class clazz)
.
noRollbackForClassName()
,
DefaultTransactionAttribute.rollbackOn(Throwable)
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class, member="noRollbackForClassName") public abstract java.lang.String[] noRollbackForClassName
Throwable
) indicating which exception types must not
cause a transaction rollback.
See the description of rollbackForClassName()
for further
information on how the specified names are treated.
Similar to NoRollbackRuleAttribute(String exceptionName)
.
noRollbackFor()
,
DefaultTransactionAttribute.rollbackOn(Throwable)