Annotation Interface TransactionalReadReplica


@Target({METHOD,TYPE}) @Retention(RUNTIME) @Transactional(transactionManager="readReplicaTransactionManager", readOnly=true) public @interface TransactionalReadReplica
Meta-annotation for @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 Elements
    Modifier and Type
    Optional Element
    Description
    org.springframework.transaction.annotation.Isolation
    The transaction isolation level.
    Class<? extends Throwable>[]
    Defines zero (0) or more exception types, which must be subclasses of Throwable, indicating which exception types must not cause a transaction rollback.
    Defines zero (0) or more exception name patterns (for exceptions which must be a subclass of Throwable) indicating which exception types must not cause a transaction rollback.
    org.springframework.transaction.annotation.Propagation
    The transaction propagation type.
    Class<? extends Throwable>[]
    Defines zero (0) or more exception types, which must be subclasses of Throwable, indicating which exception types must cause a transaction rollback.
    Defines zero (0) or more exception name patterns (for exceptions which must be a subclass of Throwable), indicating which exception types must cause a transaction rollback.
    int
    The 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 propagation
      The transaction propagation type.

      Defaults to Propagation.REQUIRED.

      See Also:
      • TransactionDefinition.getPropagationBehavior()
      Default:
      REQUIRED
    • isolation

      @AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) org.springframework.transaction.annotation.Isolation isolation
      The transaction isolation level.

      Defaults to Isolation.DEFAULT.

      Exclusively designed for use with Propagation.REQUIRED or Propagation.REQUIRES_NEW since 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:
      • TransactionDefinition.getIsolationLevel()
      • AbstractPlatformTransactionManager.setValidateExistingTransaction(boolean)
      Default:
      DEFAULT
    • timeout

      @AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) int timeout
      The timeout for this transaction (in seconds).

      Defaults to the default timeout of the underlying transaction system.

      Exclusively designed for use with Propagation.REQUIRED or Propagation.REQUIRES_NEW since it only applies to newly started transactions.

      Returns:
      the timeout in seconds
      See Also:
      • TransactionDefinition.getTimeout()
      Default:
      -1
    • timeoutString

      @AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) String timeoutString
      The timeout for this transaction (in seconds).

      Defaults to the default timeout of the underlying transaction system.

      Exclusively designed for use with Propagation.REQUIRED or Propagation.REQUIRES_NEW since 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:
      • TransactionDefinition.getTimeout()
      Default:
      ""
    • rollbackFor

      @AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) Class<? extends Throwable>[] rollbackFor
      Defines zero (0) or more exception types, which must be subclasses of Throwable, indicating which exception types must cause a transaction rollback.

      By default, a transaction will be rolled 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 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[] rollbackForClassName
      Defines zero (0) or more exception name patterns (for exceptions which must be a subclass of Throwable), 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:
      • rollbackFor()
      • RollbackRuleAttribute(String)
      • DefaultTransactionAttribute.rollbackOn(Throwable)
      Default:
      {}
    • noRollbackFor

      @AliasFor(annotation=org.springframework.transaction.annotation.Transactional.class) Class<? extends Throwable>[] noRollbackFor
      Defines zero (0) or more exception types, 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 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[] noRollbackForClassName
      Defines zero (0) or more exception name patterns (for exceptions which must be a subclass of Throwable) 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:
      • noRollbackFor()
      • NoRollbackRuleAttribute(String)
      • DefaultTransactionAttribute.rollbackOn(Throwable)
      Default:
      {}