- All Implemented Interfaces:
SqlClient
,SqlOperations
,UnsafeSqlOperations
A Vert.x connection SQL client wrapper.
This SQL client implementation supports transaction.
- Since:
- 1.2
- Author:
- Jeremy Kuhn
-
Field Summary
Fields inherited from class io.inverno.mod.sql.vertx.internal.AbstractSqlOperations
client
-
Constructor Summary
ConstructorDescriptionConnectionSqlClient
(io.vertx.sqlclient.SqlConnection connection) Creates a SQL client with the specified Vert.x SQL connection. -
Method Summary
Modifier and TypeMethodDescription<T> Publisher
<T> connection
(Function<SqlOperations, Publisher<T>> function) Executes the specified function in the scope of the connection but does not close the connection when the returned publisher terminates.onClose()
Notifies when the SQL client connection is closed.preparedStatement
(String sql) Creates a prepared SQL statement.Returns transactional SQL operations exposing commit() and rollback() method when the implementation supports it.<T> Publisher
<T> transaction
(Function<SqlOperations, Publisher<T>> function) Executes the specified function within a transaction.Methods inherited from class io.inverno.mod.sql.vertx.internal.AbstractSqlClient
close
Methods inherited from class io.inverno.mod.sql.vertx.internal.AbstractSqlOperations
batchQueries, batchUpdate, batchUpdate, query, query, queryForObject, statement, update
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.inverno.mod.sql.SqlOperations
batchUpdate, batchUpdate, query, query, queryForObject, statement, update
-
Constructor Details
-
ConnectionSqlClient
public ConnectionSqlClient(io.vertx.sqlclient.SqlConnection connection) Creates a SQL client with the specified Vert.x SQL connection.
- Parameters:
connection
- a Vert.x SQL connection
-
-
Method Details
-
preparedStatement
Description copied from interface:SqlOperations
Creates a prepared SQL statement.
Prepared statements are pre-compiled and protect against SQL injection attacks.
- Specified by:
preparedStatement
in interfaceSqlOperations
- Overrides:
preparedStatement
in classio.inverno.mod.sql.vertx.internal.AbstractSqlOperations
- Parameters:
sql
- the SQL to execute- Returns:
- a new prepared statement
-
transaction
Description copied from interface:SqlClient
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
Description copied from interface:SqlClient
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
-
connection
Executes the specified function in the scope of the connection but does not close the connection when the returned publisher terminates.
- Type Parameters:
T
- The type of results- Parameters:
function
- the function to be run using a single connection- Returns:
- a publisher
-
onClose
Notifies when the SQL client connection is closed.
- Returns:
- a mono completing empty when the connection has been closed without errors, or failing when the connection was closed with error.
-