- All Superinterfaces:
SqlOperations
A SQL Client exposes reactive method to query a RDBMS using SQL.
Support for transaction is implementation specific and depends on the underlying client.
- Since:
- 1.2
- Author:
- Jeremy Kuhn
-
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>close()Closes the SQL client and free resources.<T> org.reactivestreams.Publisher<T>connection(Function<SqlOperations, org.reactivestreams.Publisher<T>> function) Executes the specified function within a single connection.reactor.core.publisher.Mono<TransactionalSqlOperations>Returns transactional SQL operations exposing commit() and rollback() method when the implementation supports it.<T> org.reactivestreams.Publisher<T>transaction(Function<SqlOperations, org.reactivestreams.Publisher<T>> function) Executes the specified function within a transaction.Methods inherited from interface io.inverno.mod.sql.SqlOperations
batchUpdate, batchUpdate, preparedStatement, query, query, queryForObject, statement, update
-
Method Details
-
transaction
reactor.core.publisher.Mono<TransactionalSqlOperations> transaction()Returns transactional SQL operations exposing commit() and rollback() method when the implementation supports it.
This method should be used when there is a need for explicit transaction management.
The transaction MUST be explicitly committed or rolled back in order to free resources.
- Returns:
- a Mono emitting a transactional SQL operations object
-
transaction
<T> org.reactivestreams.Publisher<T> transaction(Function<SqlOperations, org.reactivestreams.Publisher<T>> function) Executes the specified function within a transaction.
All SQL operations performed within the function using the SQL operations argument will be executed within a transaction.
The transaction is created when the returned publisher is subscribed and committed when the publisher returned by the function returned successfully, it is rolled back otherwise (error or cancel).
- Type Parameters:
T- The type of results- Parameters:
function- the transactional function to be run in a transaction- Returns:
- a publisher of result
- Throws:
UnsupportedOperationException- if the implementation does not support transaction
-
connection
<T> org.reactivestreams.Publisher<T> connection(Function<SqlOperations, org.reactivestreams.Publisher<T>> function) Executes the specified function within a single connection.
All SQL operations performed within the function using the SQL operations argument will be executed using the same connection.
The connection is obtained when the returned publisher is subscribed and closed when it terminates (complete, error or cancel).
Whether connections are reused (pool) or created is implementation specific.
- Type Parameters:
T- The type of results- Parameters:
function- the function to be run using a single connection- Returns:
- a publisher
-
close
reactor.core.publisher.Mono<Void> close()Closes the SQL client and free resources.
- Returns:
- a Mono that completes when the client is closed
-