Class TransactionManagerConfiguration
- Since:
- 4.0.0
- Author:
- Denis Stepanov
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptiondetermineTimeout(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.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.booleanDeprecated, for removal: This API element is subject to removal in a future version.final booleanDeprecated, for removal: This API element is subject to removal in a future version.final booleanDeprecated, 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 booleanDeprecated, for removal: This API element is subject to removal in a future version.Has no effect: no transaction manager reads this setting.final booleanDeprecated, for removal: This API element is subject to removal in a future version.final booleanDeprecated, 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 voidsetDefaultTimeout(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.voidsetEnforceReadOnly(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 byTransactionDefinition.isReadOnly()) through an explicit statement on the transactional connection: "SET TRANSACTION READ ONLY" as understood by Oracle, MySQL and Postgres.final voidsetFailEarlyOnGlobalRollbackOnly(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 voidsetGlobalRollbackOnParticipationFailure(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 voidsetNestedTransactionAllowed(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 voidsetRollbackOnCommitFailure(boolean rollbackOnCommitFailure) Deprecated, for removal: This API element is subject to removal in a future version.Set whetherdoRollbackshould be performed on failure of thedoCommitcall.final voidsetValidateExistingTransaction(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.
-
Constructor Details
-
TransactionManagerConfiguration
public TransactionManagerConfiguration()Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Details
-
setDefaultTimeout
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_DEFAULTvalue.- Parameters:
defaultTimeout- The default timeout- See Also:
-
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_DEFAULTto 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. WhetherNESTEDpropagation 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, for removal: This API element is subject to removal in a future version.Has no effect: no transaction manager reads this setting. WhetherNESTEDpropagation 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, 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
@Transactionalinterceptor 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 explicitsetRollbackOnlycalls on aTransactionStatus, 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 whetherdoRollbackshould be performed on failure of thedoCommitcall. 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
doRollbackshould be performed on failure of thedoCommitcall.
-
determineTimeout
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 byTransactionDefinition.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:
-
nestedTransactionAllowed,validateExistingTransactionandglobalRollbackOnParticipationFailureare not implemented: whetherNESTEDpropagation 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 onDataSourceTransactionManager#setEnforceReadOnly(boolean). This class will be removed in a future release.