Class SpringHibernateTransactionOperations
java.lang.Object
io.micronaut.data.spring.hibernate.SpringHibernateTransactionOperations
- All Implemented Interfaces:
TransactionOperations<Connection>
@Requires(classes=org.springframework.orm.hibernate5.HibernateTransactionManager.class)
@EachBean(org.springframework.orm.hibernate5.HibernateTransactionManager.class)
@Internal
@Replaces(SpringJdbcTransactionOperations.class)
public class SpringHibernateTransactionOperations
extends Object
implements TransactionOperations<Connection>
Adds Spring Transaction management capability to Micronaut Data.
- Since:
- 1.0.0
- Author:
- graemerocher
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSpringHibernateTransactionOperations(org.springframework.orm.hibernate5.HibernateTransactionManager hibernateTransactionManager) Default constructor. -
Method Summary
Modifier and TypeMethodDescription<R> Rexecute(TransactionDefinition definition, TransactionCallback<Connection, R> callback) Execute a transaction within the context of the function.<R> RexecuteRead(TransactionCallback<Connection, R> callback) Execute a read-only transaction within the context of the function.<R> RexecuteWrite(TransactionCallback<Connection, R> callback) Execute a default transaction within the context of the function.Obtains the connection for the current transaction.booleanCheck if the connection exists.
-
Constructor Details
-
SpringHibernateTransactionOperations
protected SpringHibernateTransactionOperations(org.springframework.orm.hibernate5.HibernateTransactionManager hibernateTransactionManager) Default constructor.- Parameters:
hibernateTransactionManager- The hibernate transaction manager.
-
-
Method Details
-
executeRead
Description copied from interface:TransactionOperationsExecute a read-only transaction within the context of the function.- Specified by:
executeReadin interfaceTransactionOperations<Connection>- Type Parameters:
R- The result- Parameters:
callback- The call back- Returns:
- The result
-
executeWrite
Description copied from interface:TransactionOperationsExecute a default transaction within the context of the function.- Specified by:
executeWritein interfaceTransactionOperations<Connection>- Type Parameters:
R- The result- Parameters:
callback- The call back- Returns:
- The result
-
getConnection
Description copied from interface:TransactionOperationsObtains the connection for the current transaction.- Specified by:
getConnectionin interfaceTransactionOperations<Connection>- Returns:
- The connection
-
hasConnection
public boolean hasConnection()Description copied from interface:TransactionOperationsCheck if the connection exists.- Specified by:
hasConnectionin interfaceTransactionOperations<Connection>- Returns:
- True if transaction exists
-
execute
public <R> R execute(@NonNull TransactionDefinition definition, @NonNull TransactionCallback<Connection, R> callback) Description copied from interface:TransactionOperationsExecute a transaction within the context of the function.- Specified by:
executein interfaceTransactionOperations<Connection>- Type Parameters:
R- The result- Parameters:
definition- The transaction definitioncallback- The call back- Returns:
- The result
-