Package io.micronaut.data.connection
Interface ConnectionOperations<C>
- Type Parameters:
C
- The connection type.
- All Known Subinterfaces:
DataSourceConnectionOperations
,MongoConnectionOperations
- All Known Implementing Classes:
AbstractConnectionOperations
,DefaultDataSourceConnectionOperations
,HibernateConnectionConnectionOperations
,HibernateConnectionOperations
,SpringHibernateConnectionOperations
,SpringJdbcConnectionOperations
,SynchronousConnectionOperationsFromReactiveConnectionOperations
public interface ConnectionOperations<C>
The synchronous connection operations interface.
- Since:
- 4.0.0
- Author:
- Denis Stepanov
-
Method Summary
Modifier and TypeMethodDescription<R> R
execute
(@NonNull ConnectionDefinition definition, @NonNull Function<ConnectionStatus<C>, R> callback) Execute a connection within the context of the function.default <R> R
executeRead
(@NonNull Function<ConnectionStatus<C>, R> callback) Execute a read-only connection within the context of the function.default <R> R
executeWrite
(@NonNull Function<ConnectionStatus<C>, R> callback) Execute a write supported connection within the context of the function.Obtains the current connection.default @NonNull ConnectionStatus<C>
Obtains the current required connection.
-
Method Details
-
getConnectionStatus
Obtains the current required connection.- Returns:
- The connection or exception if the connection doesn't exist
-
findConnectionStatus
Optional<ConnectionStatus<C>> findConnectionStatus()Obtains the current connection.- Returns:
- The optional connection
-
execute
<R> R execute(@NonNull @NonNull ConnectionDefinition definition, @NonNull @NonNull Function<ConnectionStatus<C>, R> callback) Execute a connection within the context of the function.- Type Parameters:
R
- The result- Parameters:
definition
- The connection definitioncallback
- The call back- Returns:
- The result
-
executeRead
Execute a read-only connection within the context of the function. NOTE: The connection manager might not support the read only connection!- Type Parameters:
R
- The result- Parameters:
callback
- The call back- Returns:
- The result
-
executeWrite
Execute a write supported connection within the context of the function.- Type Parameters:
R
- The result- Parameters:
callback
- The call back- Returns:
- The result
-