Package io.micronaut.transaction
Interface TransactionOperations<T>
- Type Parameters:
T
- The resource type, such as the connection.
- All Known Subinterfaces:
MongoTransactionOperations
,SynchronousTransactionManager<T>
- All Known Implementing Classes:
AbstractDefaultTransactionOperations
,AbstractPropagatedStatusTransactionOperations
,AbstractSpringTransactionOperations
,AbstractTransactionOperations
,DataSourceTransactionManager
,HibernateTransactionManager
,SpringHibernateTransactionOperations
,SpringJdbcTransactionOperations
,SynchronousTransactionOperationsFromReactiveTransactionOperations
public interface TransactionOperations<T>
Generic transaction operations interface.
- Since:
- 1.0.0
- Author:
- graemerocher
-
Method Summary
Modifier and TypeMethodDescription<R> R
execute
(@NonNull TransactionDefinition definition, @NonNull TransactionCallback<T, R> callback) Execute a transaction within the context of the function.default <R> R
executeRead
(@NonNull TransactionCallback<T, R> callback) Execute a read-only transaction within the context of the function.default <R> R
executeWrite
(@NonNull TransactionCallback<T, R> callback) Execute a default transaction within the context of the function.Optional<? extends TransactionStatus<?>>
Find optional propagated transaction status.Obtains the connection for the current transaction.boolean
Check if the connection exists.
-
Method Details
-
getConnection
Obtains the connection for the current transaction.- Returns:
- The connection
- Throws:
NoTransactionException
- if no connection exists for the current transaction
-
hasConnection
boolean hasConnection()Check if the connection exists.- Returns:
- True if transaction exists
- Since:
- 3.3
-
findTransactionStatus
Optional<? extends TransactionStatus<?>> findTransactionStatus()Find optional propagated transaction status.- Returns:
- The transaction status.
-
execute
<R> R execute(@NonNull @NonNull TransactionDefinition definition, @NonNull @NonNull TransactionCallback<T, R> callback) Execute a transaction within the context of the function.- Type Parameters:
R
- The result- Parameters:
definition
- The transaction definitioncallback
- The call back- Returns:
- The result
-
executeRead
Execute a read-only transaction within the context of the function.- Type Parameters:
R
- The result- Parameters:
callback
- The call back- Returns:
- The result
-
executeWrite
Execute a default transaction within the context of the function.- Type Parameters:
R
- The result- Parameters:
callback
- The call back- Returns:
- The result
-