- java.lang.Object
-
- io.helidon.dbclient.common.AbstractDbExecute
-
- All Implemented Interfaces:
DbExecute
- Direct Known Subclasses:
MongoDbExecute
public abstract class AbstractDbExecute extends Object implements DbExecute
Implements methods that do not require implementation for each provider.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractDbExecute(DbStatements statements)Create an instance with configured statements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DbStatementDmlcreateDelete(String statement)Create a delete statement using a statement text.DbStatementDmlcreateDmlStatement(String statement)Create a data modification statement using a statement passed as an argument.DbStatementGetcreateGet(String statement)Create a database query returning a single row using a statement passed as an argument.DbStatementDmlcreateInsert(String statement)Create an insert statement using a statement text.DbStatementDmlcreateNamedDelete(String statementName)Create andelete statement using a named statement.DbStatementDmlcreateNamedDmlStatement(String statementName)Create a data modification statement using a statement defined in the configuration file.DbStatementGetcreateNamedGet(String statementName)Create a database query returning a single row using a statement defined in the configuration file.DbStatementDmlcreateNamedInsert(String statementName)Create an insert statement using a named statement.DbStatementQuerycreateNamedQuery(String statementName)Create a database query using a statement defined in the configuration file.DbStatementDmlcreateNamedUpdate(String statementName)Create an update statement using a named statement.DbStatementQuerycreateQuery(String statement)Create a database query using a statement passed as an argument.DbStatementDmlcreateUpdate(String statement)Create an update statement using a statement text.protected StringgenerateName(DbStatementType type, String statement)Generate a name for a statement.protected StringstatementText(String name)Return a statement text based on the statement name.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.helidon.dbclient.DbExecute
createNamedDelete, createNamedDmlStatement, createNamedGet, createNamedInsert, createNamedQuery, createNamedUpdate, delete, dml, get, insert, namedDelete, namedDml, namedGet, namedInsert, namedQuery, namedUpdate, query, unwrap, update
-
-
-
-
Constructor Detail
-
AbstractDbExecute
protected AbstractDbExecute(DbStatements statements)
Create an instance with configured statements.- Parameters:
statements- statements to obtains named statements, esp. forstatementText(String).
-
-
Method Detail
-
statementText
protected String statementText(String name)
Return a statement text based on the statement name. This is a utility method that probably would useDbStatementsto retrieve the named statements.- Parameters:
name- name of the statement- Returns:
- statement text
-
createNamedQuery
public DbStatementQuery createNamedQuery(String statementName)
Description copied from interface:DbExecuteCreate a database query using a statement defined in the configuration file.- Specified by:
createNamedQueryin interfaceDbExecute- Parameters:
statementName- the name of the configuration node with statement- Returns:
- database statement that can process query returning multiple rows
-
createQuery
public DbStatementQuery createQuery(String statement)
Description copied from interface:DbExecuteCreate a database query using a statement passed as an argument.- Specified by:
createQueryin interfaceDbExecute- Parameters:
statement- the query statement to be executed- Returns:
- database statement that can process the query returning multiple rows
-
createNamedGet
public DbStatementGet createNamedGet(String statementName)
Description copied from interface:DbExecuteCreate a database query returning a single row using a statement defined in the configuration file.- Specified by:
createNamedGetin interfaceDbExecute- Parameters:
statementName- the name of the configuration node with statement- Returns:
- database statement that can process query returning a single row
-
createGet
public DbStatementGet createGet(String statement)
Description copied from interface:DbExecuteCreate a database query returning a single row using a statement passed as an argument.
-
createNamedInsert
public DbStatementDml createNamedInsert(String statementName)
Description copied from interface:DbExecuteCreate an insert statement using a named statement.- Specified by:
createNamedInsertin interfaceDbExecute- Parameters:
statementName- the name of the statement- Returns:
- database statement that can insert data
-
createInsert
public DbStatementDml createInsert(String statement)
Description copied from interface:DbExecuteCreate an insert statement using a statement text.- Specified by:
createInsertin interfaceDbExecute- Parameters:
statement- the statement text- Returns:
- database statement that can insert data
-
createNamedUpdate
public DbStatementDml createNamedUpdate(String statementName)
Description copied from interface:DbExecuteCreate an update statement using a named statement.- Specified by:
createNamedUpdatein interfaceDbExecute- Parameters:
statementName- the name of the statement- Returns:
- database statement that can update data
-
createUpdate
public DbStatementDml createUpdate(String statement)
Description copied from interface:DbExecuteCreate an update statement using a statement text.- Specified by:
createUpdatein interfaceDbExecute- Parameters:
statement- the statement text- Returns:
- database statement that can update data
-
createNamedDelete
public DbStatementDml createNamedDelete(String statementName)
Description copied from interface:DbExecuteCreate andelete statement using a named statement.- Specified by:
createNamedDeletein interfaceDbExecute- Parameters:
statementName- the name of the statement- Returns:
- database statement that can delete data
-
createDelete
public DbStatementDml createDelete(String statement)
Description copied from interface:DbExecuteCreate a delete statement using a statement text.- Specified by:
createDeletein interfaceDbExecute- Parameters:
statement- the statement text- Returns:
- database statement that can delete data
-
createNamedDmlStatement
public DbStatementDml createNamedDmlStatement(String statementName)
Description copied from interface:DbExecuteCreate a data modification statement using a statement defined in the configuration file.- Specified by:
createNamedDmlStatementin interfaceDbExecute- Parameters:
statementName- the name of the configuration node with statement- Returns:
- data modification statement
-
createDmlStatement
public DbStatementDml createDmlStatement(String statement)
Description copied from interface:DbExecuteCreate a data modification statement using a statement passed as an argument.- Specified by:
createDmlStatementin interfaceDbExecute- Parameters:
statement- the data modification statement to be executed- Returns:
- data modification statement
-
generateName
protected String generateName(DbStatementType type, String statement)
Generate a name for a statement. The default implementation usesSHA-256so the same name is always returned for the same statement.As there is always a small risk of duplicity, named statements are recommended!
- Parameters:
type- type of the statementstatement- statement that it going to be executed- Returns:
- name of the statement
-
-