Annotation Interface TransactionalReadReplica
@Transactional that indicates that a read-only transaction should be
started on a read-only replica instance of a database.
Note that read replicas might offer only eventual consistency, which means that the data might not yet be up-to-date
when reading from a read replica. I.e. AWS RDS Read Replicas might have a replication lag of a few milliseconds until
their page cache is up-to-date compared to the primary instance.-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionorg.springframework.transaction.annotation.IsolationThe transaction isolation level.String[]Defines zero (0) or more exception name patterns (for exceptions which must be a subclass ofThrowable) indicating which exception types must not cause a transaction rollback.org.springframework.transaction.annotation.PropagationThe transaction propagation type.String[]Defines zero (0) or more exception name patterns (for exceptions which must be a subclass ofThrowable), indicating which exception types must cause a transaction rollback.intThe timeout for this transaction (in seconds).The timeout for this transaction (in seconds).
-
Element Details
-
propagation
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) org.springframework.transaction.annotation.Propagation propagationThe transaction propagation type.Defaults to
Propagation.REQUIRED.- See Also:
- Default:
REQUIRED
-
isolation
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) org.springframework.transaction.annotation.Isolation isolationThe transaction isolation level.Defaults to
Isolation.DEFAULT.Exclusively designed for use with
Propagation.REQUIREDorPropagation.REQUIRES_NEWsince it only applies to newly started transactions. Consider switching the "validateExistingTransactions" flag to "true" on your transaction manager if you'd like isolation level declarations to get rejected when participating in an existing transaction with a different isolation level.- See Also:
- Default:
DEFAULT
-
timeout
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) int timeoutThe timeout for this transaction (in seconds).Defaults to the default timeout of the underlying transaction system.
Exclusively designed for use with
Propagation.REQUIREDorPropagation.REQUIRES_NEWsince it only applies to newly started transactions.- Returns:
- the timeout in seconds
- See Also:
- Default:
-1
-
timeoutString
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) String timeoutStringThe timeout for this transaction (in seconds).Defaults to the default timeout of the underlying transaction system.
Exclusively designed for use with
Propagation.REQUIREDorPropagation.REQUIRES_NEWsince it only applies to newly started transactions.- Returns:
- the timeout in seconds as a String value, e.g. a placeholder
- Since:
- 5.3
- See Also:
- Default:
""
-
rollbackFor
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) Class<? extends Throwable>[] rollbackForDefines zero (0) or more exception types, which must be subclasses ofThrowable, indicating which exception types must cause a transaction rollback.By default, a transaction will be rolled back on
RuntimeExceptionandErrorbut not on checked exceptions (business exceptions). SeeDefaultTransactionAttribute.rollbackOn(Throwable)for a detailed explanation.This is the preferred way to construct a rollback rule (in contrast to
rollbackForClassName()), matching the exception type and its subclasses in a type-safe manner. See the class-level javadocs for further details on rollback rule semantics.- See Also:
- Default:
{}
-
rollbackForClassName
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) String[] rollbackForClassNameDefines zero (0) or more exception name patterns (for exceptions which must be a subclass ofThrowable), indicating which exception types must cause a transaction rollback.See the class-level javadocs for further details on rollback rule semantics, patterns, and warnings regarding possible unintentional matches.
- See Also:
- Default:
{}
-
noRollbackFor
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) Class<? extends Throwable>[] noRollbackForDefines zero (0) or more exceptiontypes, which must be subclasses ofThrowable, 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 type and its subclasses in a type-safe manner. See the class-level javadocs for further details on rollback rule semantics.- See Also:
- Default:
{}
-
noRollbackForClassName
@AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) String[] noRollbackForClassNameDefines zero (0) or more exception name patterns (for exceptions which must be a subclass ofThrowable) indicating which exception types must not cause a transaction rollback.See the class-level javadocs for further details on rollback rule semantics, patterns, and warnings regarding possible unintentional matches.
- See Also:
- Default:
{}
-