-
- All Known Subinterfaces:
DbTransaction
- All Known Implementing Classes:
AbstractDbExecute
,MongoDbExecute
,MongoDbTransaction
public interface DbExecute
Database executor.The database executor provides methods to create
DbStatement
instances for different types of database statements.The recommended approach is to use named statements, as that allows better metrics, tracing, logging etc. In case an unnamed statement is used, a name must be generated
There are five methods for each
DbStatementType
, example for query (the implementation detail is for the default implementation, providers may differ):DbStatement
createNamedQuery(String, String)
- full control over the name and content of the statementDbStatement
createNamedQuery(String)
- use statement text from configurationDbStatement
createQuery(String)
- use the provided statement, name is generatedDbRowResult
namedQuery(String, Object...)
- shortcut method to a named query with a list of parameters (or with no parameters at all)DbRowResult
query(String, Object...)
- shortcut method to unnamed query with a list of parameters (or with no parameters at all)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description DbStatementDml
createDelete(String statement)
Create a delete statement using a statement text.DbStatementDml
createDmlStatement(String statement)
Create a data modification statement using a statement passed as an argument.DbStatementGet
createGet(String statement)
Create a database query returning a single row using a statement passed as an argument.DbStatementDml
createInsert(String statement)
Create an insert statement using a statement text.DbStatementDml
createNamedDelete(String statementName)
Create andelete statement using a named statement.default DbStatementDml
createNamedDelete(String statementName, String statement)
Create a delete statement using a named statement passed as an argument.DbStatementDml
createNamedDmlStatement(String statementName)
Create a data modification statement using a statement defined in the configuration file.DbStatementDml
createNamedDmlStatement(String statementName, String statement)
Create a data modification statement using a named statement passed as an argument.DbStatementGet
createNamedGet(String statementName)
Create a database query returning a single row using a statement defined in the configuration file.DbStatementGet
createNamedGet(String statementName, String statement)
Create a database query returning a single row using a named statement passed as an argument.DbStatementDml
createNamedInsert(String statementName)
Create an insert statement using a named statement.default DbStatementDml
createNamedInsert(String statementName, String statement)
Create an insert statement using a named statement passed as an argument.DbStatementQuery
createNamedQuery(String statementName)
Create a database query using a statement defined in the configuration file.DbStatementQuery
createNamedQuery(String statementName, String statement)
Create a database query using a named statement passed as argument.DbStatementDml
createNamedUpdate(String statementName)
Create an update statement using a named statement.default DbStatementDml
createNamedUpdate(String statementName, String statement)
Create an update statement using a named statement passed as an argument.DbStatementQuery
createQuery(String statement)
Create a database query using a statement passed as an argument.DbStatementDml
createUpdate(String statement)
Create an update statement using a statement text.default Single<Long>
delete(String statement, Object... parameters)
Create and execute delete statement using a statement passed as an argument.default Single<Long>
dml(String statement, Object... parameters)
Create and execute data modification statement using a statement passed as an argument.default Single<Optional<DbRow>>
get(String statement, Object... parameters)
Create and execute a database query using a statement passed as an argument.default Single<Long>
insert(String statement, Object... parameters)
Create and execute insert statement using a statement passed as an argument.default Single<Long>
namedDelete(String statementName, Object... parameters)
Create and execute delete statement using a statement defined in the configuration file.default Single<Long>
namedDml(String statementName, Object... parameters)
Create and execute a data modification statement using a statement defined in the configuration file.default Single<Optional<DbRow>>
namedGet(String statementName, Object... parameters)
Create and execute a database query using a statement defined in the configuration file.default Single<Long>
namedInsert(String statementName, Object... parameters)
Create and execute insert statement using a statement defined in the configuration file.default Multi<DbRow>
namedQuery(String statementName, Object... parameters)
Create and execute a database query using a statement defined in the configuration file.default Single<Long>
namedUpdate(String statementName, Object... parameters)
Create and execute update statement using a statement defined in the configuration file.default Multi<DbRow>
query(String statement, Object... parameters)
Create and execute a database query using a statement passed as an argument.<C> Single<C>
unwrap(Class<C> cls)
Unwrap database executor internals.default Single<Long>
update(String statement, Object... parameters)
Create and execute update statement using a statement passed as an argument.
-
-
-
Method Detail
-
createNamedQuery
DbStatementQuery createNamedQuery(String statementName, String statement)
Create a database query using a named statement passed as argument.- Parameters:
statementName
- the name of the statementstatement
- the query statement- Returns:
- database statement that can process query returning multiple rows
-
createNamedQuery
DbStatementQuery createNamedQuery(String statementName)
Create a database query using a statement defined in the configuration file.- Parameters:
statementName
- the name of the configuration node with statement- Returns:
- database statement that can process query returning multiple rows
-
createQuery
DbStatementQuery createQuery(String statement)
Create a database query using a statement passed as an argument.- Parameters:
statement
- the query statement to be executed- Returns:
- database statement that can process the query returning multiple rows
-
namedQuery
default Multi<DbRow> namedQuery(String statementName, Object... parameters)
Create and execute a database query using a statement defined in the configuration file.- Parameters:
statementName
- the name of the configuration node with statementparameters
- query parameters to set- Returns:
- database query execution result which can contain multiple rows
-
query
default Multi<DbRow> query(String statement, Object... parameters)
Create and execute a database query using a statement passed as an argument.- Parameters:
statement
- the query statement to be executedparameters
- query parameters to set- Returns:
- database query execution result which can contain multiple rows
-
createNamedGet
DbStatementGet createNamedGet(String statementName, String statement)
Create a database query returning a single row using a named statement passed as an argument.- Parameters:
statementName
- the name of the statementstatement
- the statement text- Returns:
- database statement that can process query returning a single row
-
createNamedGet
DbStatementGet createNamedGet(String statementName)
Create a database query returning a single row using a statement defined in the configuration file.- Parameters:
statementName
- the name of the configuration node with statement- Returns:
- database statement that can process query returning a single row
-
createGet
DbStatementGet createGet(String statement)
Create a database query returning a single row using a statement passed as an argument.- Parameters:
statement
- the query statement to be executed- Returns:
- database statement that can process query returning a single row
-
namedGet
default Single<Optional<DbRow>> namedGet(String statementName, Object... parameters)
Create and execute a database query using a statement defined in the configuration file.- Parameters:
statementName
- the name of the configuration node with statementparameters
- query parameters to set- Returns:
- database query execution result which can contain single row
-
get
default Single<Optional<DbRow>> get(String statement, Object... parameters)
Create and execute a database query using a statement passed as an argument.- Parameters:
statement
- the query statement to be executedparameters
- query parameters to set- Returns:
- database query execution result which can contain single row
-
createNamedInsert
default DbStatementDml createNamedInsert(String statementName, String statement)
Create an insert statement using a named statement passed as an argument.- Parameters:
statementName
- the name of the statementstatement
- the statement text- Returns:
- database statement that can insert data
-
createNamedInsert
DbStatementDml createNamedInsert(String statementName)
Create an insert statement using a named statement.- Parameters:
statementName
- the name of the statement- Returns:
- database statement that can insert data
-
createInsert
DbStatementDml createInsert(String statement)
Create an insert statement using a statement text.- Parameters:
statement
- the statement text- Returns:
- database statement that can insert data
-
namedInsert
default Single<Long> namedInsert(String statementName, Object... parameters)
Create and execute insert statement using a statement defined in the configuration file.- Parameters:
statementName
- the name of the configuration node with statementparameters
- query parameters to set- Returns:
- number of rows inserted into the database
-
insert
default Single<Long> insert(String statement, Object... parameters)
Create and execute insert statement using a statement passed as an argument.- Parameters:
statement
- the insert statement to be executedparameters
- query parameters to set- Returns:
- number of rows inserted into the database
-
createNamedUpdate
default DbStatementDml createNamedUpdate(String statementName, String statement)
Create an update statement using a named statement passed as an argument.- Parameters:
statementName
- the name of the statementstatement
- the statement text- Returns:
- database statement that can update data
-
createNamedUpdate
DbStatementDml createNamedUpdate(String statementName)
Create an update statement using a named statement.- Parameters:
statementName
- the name of the statement- Returns:
- database statement that can update data
-
createUpdate
DbStatementDml createUpdate(String statement)
Create an update statement using a statement text.- Parameters:
statement
- the statement text- Returns:
- database statement that can update data
-
namedUpdate
default Single<Long> namedUpdate(String statementName, Object... parameters)
Create and execute update statement using a statement defined in the configuration file.- Parameters:
statementName
- the name of the configuration node with statementparameters
- query parameters to set- Returns:
- number of rows updateed into the database
-
update
default Single<Long> update(String statement, Object... parameters)
Create and execute update statement using a statement passed as an argument.- Parameters:
statement
- the update statement to be executedparameters
- query parameters to set- Returns:
- number of rows updateed into the database
-
createNamedDelete
default DbStatementDml createNamedDelete(String statementName, String statement)
Create a delete statement using a named statement passed as an argument.- Parameters:
statementName
- the name of the statementstatement
- the statement text- Returns:
- database statement that can delete data
-
createNamedDelete
DbStatementDml createNamedDelete(String statementName)
Create andelete statement using a named statement.- Parameters:
statementName
- the name of the statement- Returns:
- database statement that can delete data
-
createDelete
DbStatementDml createDelete(String statement)
Create a delete statement using a statement text.- Parameters:
statement
- the statement text- Returns:
- database statement that can delete data
-
namedDelete
default Single<Long> namedDelete(String statementName, Object... parameters)
Create and execute delete statement using a statement defined in the configuration file.- Parameters:
statementName
- the name of the configuration node with statementparameters
- query parameters to set- Returns:
- number of rows deleted from the database
-
delete
default Single<Long> delete(String statement, Object... parameters)
Create and execute delete statement using a statement passed as an argument.- Parameters:
statement
- the delete statement to be executedparameters
- query parameters to set- Returns:
- number of rows deleted from the database
-
createNamedDmlStatement
DbStatementDml createNamedDmlStatement(String statementName, String statement)
Create a data modification statement using a named statement passed as an argument.- Parameters:
statementName
- the name of the statementstatement
- the statement text- Returns:
- data modification statement
-
createNamedDmlStatement
DbStatementDml createNamedDmlStatement(String statementName)
Create a data modification statement using a statement defined in the configuration file.- Parameters:
statementName
- the name of the configuration node with statement- Returns:
- data modification statement
-
createDmlStatement
DbStatementDml createDmlStatement(String statement)
Create a data modification statement using a statement passed as an argument.- Parameters:
statement
- the data modification statement to be executed- Returns:
- data modification statement
-
namedDml
default Single<Long> namedDml(String statementName, Object... parameters)
Create and execute a data modification statement using a statement defined in the configuration file.- Parameters:
statementName
- the name of the configuration node with statementparameters
- query parameters to set- Returns:
- number of rows modified
-
dml
default Single<Long> dml(String statement, Object... parameters)
Create and execute data modification statement using a statement passed as an argument.- Parameters:
statement
- the delete statement to be executedparameters
- query parameters to set- Returns:
- number of rows modified
-
unwrap
<C> Single<C> unwrap(Class<C> cls)
Unwrap database executor internals. Only database connection is supported. Any operations based on this connection are blocking. Reactive support must be implemented in user code. This connection instance is being used to execute all statements in current database executor context.- Type Parameters:
C
- target class to be unwrapped- Parameters:
cls
- target class to be unwrapped- Returns:
- database executor internals future matching provided class
- Throws:
UnsupportedOperationException
- when provided class is not supported
-
-