Interface TransactionStatus<T>
- Type Parameters:
T
- The native transaction type
- All Superinterfaces:
Flushable
,SavepointManager
,TransactionExecution
- All Known Subinterfaces:
InternalTransaction<T>
- All Known Implementing Classes:
AbstractInternalTransaction
,DefaultTransactionStatus
TransactionStatus
modernizing it
to use enums, Slf4j and decoupling from Spring.
Representation of the status of a transaction.
Transactional code can use this to retrieve status information, and to programmatically request a rollback (instead of throwing an exception that causes an implicit rollback).
Includes the SavepointManager
interface to provide access
to savepoint management facilities. Note that savepoint management
is only available if supported by the underlying transaction manager.
- Since:
- 27.03.2003
- Author:
- Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
flush()
Flush the underlying session to the datastore, if applicable: for example, all affected Hibernate/JPA sessions.default T
@NonNull ConnectionStatus<T>
@Nullable Object
boolean
Return whether this transaction internally carries a savepoint, that is, has been created as nested transaction based on a savepoint.default void
registerSynchronization
(@NonNull TransactionSynchronization synchronization) Register a new transaction synchronization for the current state.Methods inherited from interface io.micronaut.transaction.SavepointManager
createSavepoint, releaseSavepoint, rollbackToSavepoint
Methods inherited from interface io.micronaut.transaction.TransactionExecution
getTransactionDefinition, isCompleted, isNewTransaction, isRollbackOnly, setRollbackOnly
-
Method Details
-
hasSavepoint
boolean hasSavepoint()Return whether this transaction internally carries a savepoint, that is, has been created as nested transaction based on a savepoint.This method is mainly here for diagnostic purposes, alongside
TransactionExecution.isNewTransaction()
. For programmatic handling of custom savepoints, use the operations provided bySavepointManager
.- Returns:
- Whether a save point is present
- See Also:
-
flush
default void flush()Flush the underlying session to the datastore, if applicable: for example, all affected Hibernate/JPA sessions.This is effectively just a hint and may be a no-op if the underlying transaction manager does not have a flush concept. A flush signal may get applied to the primary resource or to transaction synchronizations, depending on the underlying resource.
-
getTransaction
- Returns:
- The underlying transaction object.
-
getConnection
- Returns:
- The associated connection.
-
getConnectionStatus
- Returns:
- The connection status.
- Since:
- 4.0.0
-
registerSynchronization
Register a new transaction synchronization for the current state.Note that synchronizations can implement the
Ordered
interface. They will be executed in an order according to their order value (if any).- Parameters:
synchronization
- the synchronization object to register
-