Package io.micronaut.transaction
Interface TransactionOperations<T>
-
- Type Parameters:
T- The resource type, such as the connection.
- All Known Subinterfaces:
ResourceTransactionManager<R,T>,SynchronousTransactionManager<T>
- All Known Implementing Classes:
AbstractSynchronousTransactionManager,DataSourceTransactionManager,HibernateTransactionManager,MongoSynchronousTransactionManager,SpringHibernateTransactionOperations,SpringJdbcTransactionOperations,SynchronousFromReactiveTransactionManager
public interface TransactionOperations<T>Generic transaction operations interface.- Since:
- 1.0.0
- Author:
- graemerocher
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <R> Rexecute(TransactionDefinition definition, TransactionCallback<T,R> callback)Execute a transaction within the context of the function.<R> RexecuteRead(TransactionCallback<T,R> callback)Execute a read-only transaction within the context of the function.<R> RexecuteWrite(TransactionCallback<T,R> callback)Execute a default transaction within the context of the function.TgetConnection()Obtains the connection for the current transaction.booleanhasConnection()Check if the connection exists.
-
-
-
Method Detail
-
getConnection
@NonNull T 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
<R> R executeRead(@NonNull TransactionCallback<T,R> callback)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
<R> R executeWrite(@NonNull TransactionCallback<T,R> callback)Execute a default transaction within the context of the function.- Type Parameters:
R- The result- Parameters:
callback- The call back- Returns:
- The result
-
-