Package io.micronaut.data.spring.jdbc
Class SpringJdbcTransactionOperations
java.lang.Object
io.micronaut.data.spring.jdbc.SpringJdbcTransactionOperations
- All Implemented Interfaces:
TransactionOperations<Connection>
@EachBean(org.springframework.jdbc.datasource.DataSourceTransactionManager.class)
@Internal
@Requires(classes=org.springframework.jdbc.datasource.DataSourceTransactionManager.class)
public class SpringJdbcTransactionOperations
extends Object
implements TransactionOperations<Connection>
Default implementation of
TransactionOperations
that uses Spring managed transactions.- Since:
- 1.0.0
- Author:
- graemerocher
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SpringJdbcTransactionOperations
(org.springframework.jdbc.datasource.DataSourceTransactionManager transactionManager) Default constructor. -
Method Summary
Modifier and TypeMethodDescription<R> R
execute
(TransactionDefinition definition, TransactionCallback<Connection, R> callback) Execute a transaction within the context of the function.<R> R
executeRead
(TransactionCallback<Connection, R> callback) Execute a read-only transaction within the context of the function.<R> R
executeWrite
(TransactionCallback<Connection, 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.
-
Constructor Details
-
SpringJdbcTransactionOperations
protected SpringJdbcTransactionOperations(org.springframework.jdbc.datasource.DataSourceTransactionManager transactionManager) Default constructor.- Parameters:
transactionManager
- The transaction manager
-
-
Method Details
-
executeRead
Description copied from interface:TransactionOperations
Execute a read-only transaction within the context of the function.- Specified by:
executeRead
in interfaceTransactionOperations<Connection>
- Type Parameters:
R
- The result- Parameters:
callback
- The call back- Returns:
- The result
-
executeWrite
Description copied from interface:TransactionOperations
Execute a default transaction within the context of the function.- Specified by:
executeWrite
in interfaceTransactionOperations<Connection>
- Type Parameters:
R
- The result- Parameters:
callback
- The call back- Returns:
- The result
-
execute
public <R> R execute(@NonNull TransactionDefinition definition, @NonNull TransactionCallback<Connection, R> callback) Description copied from interface:TransactionOperations
Execute a transaction within the context of the function.- Specified by:
execute
in interfaceTransactionOperations<Connection>
- Type Parameters:
R
- The result- Parameters:
definition
- The transaction definitioncallback
- The call back- Returns:
- The result
-
getConnection
Description copied from interface:TransactionOperations
Obtains the connection for the current transaction.- Specified by:
getConnection
in interfaceTransactionOperations<Connection>
- Returns:
- The connection
-
hasConnection
public boolean hasConnection()Description copied from interface:TransactionOperations
Check if the connection exists.- Specified by:
hasConnection
in interfaceTransactionOperations<Connection>
- Returns:
- True if transaction exists
-