Package io.micronaut.data.spring.jdbc
Class SpringJdbcTransactionOperations
- java.lang.Object
-
- io.micronaut.data.spring.jdbc.SpringJdbcTransactionOperations
-
- All Implemented Interfaces:
TransactionOperations<java.sql.Connection>
@EachBean(org.springframework.jdbc.datasource.DataSourceTransactionManager.class) @Internal @Requires(classes=org.springframework.jdbc.datasource.DataSourceTransactionManager.class) public class SpringJdbcTransactionOperations extends java.lang.Object implements TransactionOperations<java.sql.Connection>
Default implementation ofTransactionOperationsthat uses Spring managed transactions.- Since:
- 1.0.0
- Author:
- graemerocher
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSpringJdbcTransactionOperations(org.springframework.jdbc.datasource.DataSourceTransactionManager transactionManager)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> Rexecute(TransactionDefinition definition, TransactionCallback<java.sql.Connection,R> callback)Execute a transaction within the context of the function.<R> RexecuteRead(TransactionCallback<java.sql.Connection,R> callback)Execute a read-only transaction within the context of the function.<R> RexecuteWrite(TransactionCallback<java.sql.Connection,R> callback)Execute a default transaction within the context of the function.java.sql.ConnectiongetConnection()Obtains the connection for the current transaction.booleanhasConnection()Check if the connection exists.
-
-
-
Method Detail
-
executeRead
public <R> R executeRead(@NonNull TransactionCallback<java.sql.Connection,R> callback)Description copied from interface:TransactionOperationsExecute a read-only transaction within the context of the function.- Specified by:
executeReadin interfaceTransactionOperations<java.sql.Connection>- Type Parameters:
R- The result- Parameters:
callback- The call back- Returns:
- The result
-
executeWrite
public <R> R executeWrite(@NonNull TransactionCallback<java.sql.Connection,R> callback)Description copied from interface:TransactionOperationsExecute a default transaction within the context of the function.- Specified by:
executeWritein interfaceTransactionOperations<java.sql.Connection>- Type Parameters:
R- The result- Parameters:
callback- The call back- Returns:
- The result
-
execute
public <R> R execute(@NonNull TransactionDefinition definition, @NonNull TransactionCallback<java.sql.Connection,R> callback)Description copied from interface:TransactionOperationsExecute a transaction within the context of the function.- Specified by:
executein interfaceTransactionOperations<java.sql.Connection>- Type Parameters:
R- The result- Parameters:
definition- The transaction definitioncallback- The call back- Returns:
- The result
-
getConnection
@NonNull public java.sql.Connection getConnection()
Description copied from interface:TransactionOperationsObtains the connection for the current transaction.- Specified by:
getConnectionin interfaceTransactionOperations<java.sql.Connection>- Returns:
- The connection
-
hasConnection
public boolean hasConnection()
Description copied from interface:TransactionOperationsCheck if the connection exists.- Specified by:
hasConnectionin interfaceTransactionOperations<java.sql.Connection>- Returns:
- True if transaction exists
-
-