Class TransactionManagerConfiguration

java.lang.Object
io.micronaut.transaction.impl.TransactionManagerConfiguration

@Deprecated(forRemoval=true, since="5.3") public class TransactionManagerConfiguration extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
This class is not used by any Micronaut Data transaction manager: it is neither a configuration bean nor passed to the transaction managers, so none of its settings have any effect. In particular, nestedTransactionAllowed, validateExistingTransaction and globalRollbackOnParticipationFailure are not implemented: whether NESTED propagation is supported depends only on the transaction manager (the JDBC and Hibernate transaction managers use savepoints), the isolation level and read-only setting of a joined transaction are not validated, and a participating transaction that is rolled back marks the existing transaction rollback-only. Read-only enforcement is configured on DataSourceTransactionManager#setEnforceReadOnly(boolean). This class will be removed in a future release.
The transaction manager configuration.
Since:
4.0.0
Author:
Denis Stepanov
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Determine the actual timeout to use for the given definition.
    final @NonNull Optional<Duration>
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the default timeout that this transaction manager should apply if there is no timeout specified at the transaction level, in seconds.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    final boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    final boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Has no effect: no transaction manager reads this setting and a participating transaction that is rolled back marks the existing transaction rollback-only.
    final boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Has no effect: no transaction manager reads this setting.
    final boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    final boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Has no effect: no transaction manager reads this setting and the isolation level and read-only setting of a joined transaction are not validated.
    final void
    setDefaultTimeout(Duration defaultTimeout)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Specify the default timeout that this transaction manager should apply if there is no timeout specified at the transaction level, in seconds.
    void
    setEnforceReadOnly(boolean enforceReadOnly)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Specify whether to enforce the read-only nature of a transaction (as indicated by TransactionDefinition.isReadOnly()) through an explicit statement on the transactional connection: "SET TRANSACTION READ ONLY" as understood by Oracle, MySQL and Postgres.
    final void
    setFailEarlyOnGlobalRollbackOnly(boolean failEarlyOnGlobalRollbackOnly)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set whether to fail early in case of the transaction being globally marked as rollback-only.
    final void
    setGlobalRollbackOnParticipationFailure(boolean globalRollbackOnParticipationFailure)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Has no effect: no transaction manager reads this setting and a participating transaction that is rolled back marks the existing transaction rollback-only.
    final void
    setNestedTransactionAllowed(boolean nestedTransactionAllowed)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Has no effect: no transaction manager reads this setting.
    final void
    setRollbackOnCommitFailure(boolean rollbackOnCommitFailure)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set whether doRollback should be performed on failure of the doCommit call.
    final void
    setValidateExistingTransaction(boolean validateExistingTransaction)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Has no effect: no transaction manager reads this setting and the isolation level and read-only setting of a joined transaction are not validated.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TransactionManagerConfiguration

      public TransactionManagerConfiguration()
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • setDefaultTimeout

      public final void setDefaultTimeout(Duration defaultTimeout)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specify the default timeout that this transaction manager should apply if there is no timeout specified at the transaction level, in seconds.

      Default is the underlying transaction infrastructure's default timeout, e.g. typically 30 seconds in case of a JTA provider, indicated by the TransactionDefinition.TIMEOUT_DEFAULT value.

      Parameters:
      defaultTimeout - The default timeout
      See Also:
    • getDefaultTimeout

      public final @NonNull Optional<Duration> getDefaultTimeout()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the default timeout that this transaction manager should apply if there is no timeout specified at the transaction level, in seconds.

      Returns TransactionDefinition.TIMEOUT_DEFAULT to indicate the underlying transaction infrastructure's default timeout.

      Returns:
      The default timeout
    • setNestedTransactionAllowed

      @Deprecated(forRemoval=true, since="5.3") public final void setNestedTransactionAllowed(boolean nestedTransactionAllowed)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Has no effect: no transaction manager reads this setting. Whether NESTED propagation is supported depends only on the transaction manager.
      Set whether nested transactions are allowed. Default is "false".

      Typically initialized with an appropriate default by the concrete transaction manager subclass.

      Parameters:
      nestedTransactionAllowed - Whether a nested transaction is allowed
    • isNestedTransactionAllowed

      @Deprecated(forRemoval=true, since="5.3") public final boolean isNestedTransactionAllowed()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Has no effect: no transaction manager reads this setting. Whether NESTED propagation is supported depends only on the transaction manager.
      Returns:
      Return whether nested transactions are allowed.
    • setValidateExistingTransaction

      @Deprecated(forRemoval=true, since="5.3") public final void setValidateExistingTransaction(boolean validateExistingTransaction)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Has no effect: no transaction manager reads this setting and the isolation level and read-only setting of a joined transaction are not validated.
      Set whether existing transactions should be validated before participating in them.

      When participating in an existing transaction (e.g. with PROPAGATION_REQUIRED or PROPAGATION_SUPPORTS encountering an existing transaction), this outer transaction's characteristics will apply even to the inner transaction scope. Validation will detect incompatible isolation level and read-only settings on the inner transaction definition and reject participation accordingly through throwing a corresponding exception.

      Default is "false", leniently ignoring inner transaction settings, simply overriding them with the outer transaction's characteristics. Switch this flag to "true" in order to enforce strict validation.

      Parameters:
      validateExistingTransaction - Whether to validate an existing transaction
      Since:
      2.5.1
    • isValidateExistingTransaction

      @Deprecated(forRemoval=true, since="5.3") public final boolean isValidateExistingTransaction()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Has no effect: no transaction manager reads this setting and the isolation level and read-only setting of a joined transaction are not validated.
      Return whether existing transactions should be validated before participating in them.
      Returns:
      Whether to validate existing transactions
      Since:
      2.5.1
    • setGlobalRollbackOnParticipationFailure

      @Deprecated(forRemoval=true, since="5.3") public final void setGlobalRollbackOnParticipationFailure(boolean globalRollbackOnParticipationFailure)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Has no effect: no transaction manager reads this setting and a participating transaction that is rolled back marks the existing transaction rollback-only.
      Set whether to globally mark an existing transaction as rollback-only after a participating transaction failed.

      Default is "true": If a participating transaction (e.g. with PROPAGATION_REQUIRED or PROPAGATION_SUPPORTS encountering an existing transaction) fails, the transaction will be globally marked as rollback-only. The only possible outcome of such a transaction is a rollback: The transaction originator cannot make the transaction commit anymore.

      Switch this to "false" to let the transaction originator make the rollback decision. If a participating transaction fails with an exception, the caller can still decide to continue with a different path within the transaction. However, note that this will only work as long as all participating resources are capable of continuing towards a transaction commit even after a data access failure: This is generally not the case for a Hibernate Session, for example; neither is it for a sequence of JDBC insert/update/delete operations.

      Note:This flag only applies to an explicit rollback attempt for a subtransaction, typically caused by an exception thrown by a data access operation (where the @Transactional interceptor triggers a rollback according to the transaction's rollback rule). If the flag is off, the caller can handle the exception and decide on a rollback, independent of the rollback rules of the subtransaction. This flag does, however, not apply to explicit setRollbackOnly calls on a TransactionStatus, which will always cause an eventual global rollback (as it might not throw an exception after the rollback-only call).

      The recommended solution for handling failure of a subtransaction is a "nested transaction", where the global transaction can be rolled back to a savepoint taken at the beginning of the subtransaction. propagation NESTED provides exactly those semantics; however, it will only work when nested transaction support is available. This is the case with the JDBC and Hibernate transaction managers.

      Parameters:
      globalRollbackOnParticipationFailure - Whether to globally mark transaction as rollback only
      See Also:
    • isGlobalRollbackOnParticipationFailure

      @Deprecated(forRemoval=true, since="5.3") public final boolean isGlobalRollbackOnParticipationFailure()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Has no effect: no transaction manager reads this setting and a participating transaction that is rolled back marks the existing transaction rollback-only.
      Returns:
      Return whether to globally mark an existing transaction as rollback-only after a participating transaction failed.
    • setFailEarlyOnGlobalRollbackOnly

      public final void setFailEarlyOnGlobalRollbackOnly(boolean failEarlyOnGlobalRollbackOnly)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set whether to fail early in case of the transaction being globally marked as rollback-only.

      Default is "false", only causing an UnexpectedRollbackException at the outermost transaction boundary. Switch this flag on to cause an UnexpectedRollbackException as early as the global rollback-only marker has been first detected, even from within an inner transaction boundary.

      Parameters:
      failEarlyOnGlobalRollbackOnly - Sets whether to fail early on global rollback
      Since:
      2.0
      See Also:
    • isFailEarlyOnGlobalRollbackOnly

      public final boolean isFailEarlyOnGlobalRollbackOnly()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Return whether to fail early in case of the transaction being globally marked as rollback-only.
      Since:
      2.0
    • setRollbackOnCommitFailure

      public final void setRollbackOnCommitFailure(boolean rollbackOnCommitFailure)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set whether doRollback should be performed on failure of the doCommit call. Typically not necessary and thus to be avoided, as it can potentially override the commit exception with a subsequent rollback exception.

      Default is "false".

      Parameters:
      rollbackOnCommitFailure - Sets whether to rollback on commit failure
    • isRollbackOnCommitFailure

      public final boolean isRollbackOnCommitFailure()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Return whether doRollback should be performed on failure of the doCommit call.
    • determineTimeout

      public Optional<Duration> determineTimeout(TransactionDefinition definition)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Determine the actual timeout to use for the given definition. Will fall back to this manager's default timeout if the transaction definition doesn't specify a non-default value.
      Parameters:
      definition - the transaction definition
      Returns:
      the actual timeout to use
      See Also:
    • setEnforceReadOnly

      public void setEnforceReadOnly(boolean enforceReadOnly)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specify whether to enforce the read-only nature of a transaction (as indicated by TransactionDefinition.isReadOnly()) through an explicit statement on the transactional connection: "SET TRANSACTION READ ONLY" as understood by Oracle, MySQL and Postgres.

      This mode of read-only handling goes beyond the Connection.setReadOnly(boolean) hint that Micronaut Data applies to read-only transactions by default. In contrast to that standard JDBC hint, "SET TRANSACTION READ ONLY" enforces an isolation-level-like connection mode where data manipulation statements are strictly disallowed. Also, on Oracle, this read-only mode provides read consistency for the entire transaction.

      Note that older Oracle JDBC drivers (9i, 10g) used to enforce this read-only mode even for Connection.setReadOnly(true. However, with recent drivers, this strong enforcement needs to be applied explicitly, e.g. through this flag.

      Parameters:
      enforceReadOnly - True if read-only should be enforced
      Since:
      4.3.7
    • isEnforceReadOnly

      public boolean isEnforceReadOnly()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Return whether to enforce the read-only nature of a transaction through an explicit statement on the transactional connection.
      Since:
      4.3.7
      See Also: