- 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
Modifier and TypeMethodDescriptioncreateDelete
(String statement) Create a delete statement using a statement text.createDmlStatement
(String statement) Create a data modification statement using a statement passed as an argument.Create a database query returning a single row using a statement passed as an argument.createInsert
(String statement) Create an insert statement using a statement text.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.createNamedDmlStatement
(String statementName) Create a data modification statement using a statement defined in the configuration file.createNamedDmlStatement
(String statementName, String statement) Create a data modification statement using a named statement passed as an argument.createNamedGet
(String statementName) Create a database query returning a single row using a statement defined in the configuration file.createNamedGet
(String statementName, String statement) Create a database query returning a single row using a named statement passed as an argument.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.createNamedQuery
(String statementName) Create a database query using a statement defined in the configuration file.createNamedQuery
(String statementName, String statement) Create a database query using a named statement passed as argument.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.createQuery
(String statement) Create a database query using a statement passed as an argument.createUpdate
(String statement) Create an update statement using a statement text.Create and execute delete statement using a statement passed as an argument.Create and execute data modification statement using a statement passed as an argument.Create and execute a database query using a statement passed as an argument.Create and execute insert statement using a statement passed as an argument.namedDelete
(String statementName, Object... parameters) Create and execute delete statement using a statement defined in the configuration file.Create and execute a data modification statement using a statement defined in the configuration file.Create and execute a database query using a statement defined in the configuration file.namedInsert
(String statementName, Object... parameters) Create and execute insert statement using a statement defined in the configuration file.namedQuery
(String statementName, Object... parameters) Create and execute a database query using a statement defined in the configuration file.namedUpdate
(String statementName, Object... parameters) Create and execute update statement using a statement defined in the configuration file.Create and execute a database query using a statement passed as an argument.<C> Single<C>
Unwrap database executor internals.Create and execute update statement using a statement passed as an argument.
-
Method Details
-
createNamedQuery
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
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
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
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
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
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
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
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
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
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
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
Create an insert statement using a named statement.- Parameters:
statementName
- the name of the statement- Returns:
- database statement that can insert data
-
createInsert
Create an insert statement using a statement text.- Parameters:
statement
- the statement text- Returns:
- database statement that can insert data
-
namedInsert
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
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
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
Create an update statement using a named statement.- Parameters:
statementName
- the name of the statement- Returns:
- database statement that can update data
-
createUpdate
Create an update statement using a statement text.- Parameters:
statement
- the statement text- Returns:
- database statement that can update data
-
namedUpdate
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
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
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
Create andelete statement using a named statement.- Parameters:
statementName
- the name of the statement- Returns:
- database statement that can delete data
-
createDelete
Create a delete statement using a statement text.- Parameters:
statement
- the statement text- Returns:
- database statement that can delete data
-
namedDelete
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
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
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
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
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
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
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
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
-