Package io.micronaut.transaction
Interface TransactionOperations<T>
- Type Parameters:
T
- The resource type, such as the connection.
- All Known Subinterfaces:
MongoSynchronousTransactionManager
,ResourceTransactionManager<R,
,T> SynchronousTransactionManager<T>
- All Known Implementing Classes:
AbstractSynchronousTransactionManager
,DataSourceTransactionManager
,HibernateTransactionManager
,MongoSynchronousTransactionManagerImpl
,SpringHibernateTransactionOperations
,SpringJdbcTransactionOperations
,SynchronousFromReactiveTransactionManager
public interface TransactionOperations<T>
Generic transaction operations interface.
- Since:
- 1.0.0
- Author:
- graemerocher
-
Method Summary
Modifier and TypeMethodDescription<R> R
execute
(TransactionDefinition definition, TransactionCallback<T, R> callback) Execute a transaction within the context of the function.<R> R
executeRead
(TransactionCallback<T, R> callback) Execute a read-only transaction within the context of the function.<R> R
executeWrite
(TransactionCallback<T, R> callback) Execute a default transaction within the context of the function.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
-
execute
<R> R execute(@NonNull TransactionDefinition definition, @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
-