Class DbExecuteBase

java.lang.Object
io.helidon.dbclient.DbExecuteBase
All Implemented Interfaces:
DbExecute
Direct Known Subclasses:
MongoDbExecute

public abstract class DbExecuteBase extends Object implements DbExecute
Base DbExecute implementation.
  • Constructor Details

    • DbExecuteBase

      protected DbExecuteBase(DbClientContext context)
      Create an instance of common database executor.
      Parameters:
      context - database client context
  • Method Details

    • statementText

      protected String statementText(String name)
      Return a statement text based on the statement name. This is a utility method that probably would use DbStatements to retrieve the named statements.
      Parameters:
      name - name of the statement
      Returns:
      statement text
    • context

      protected DbClientContext context()
      Return database client context.
      Returns:
      database client context
    • context

      protected <C extends DbClientContext> C context(Class<C> cls)
      Return database client context cast to it's extending class.
      Type Parameters:
      C - client context extending type
      Parameters:
      cls - DbClientContext extending class
      Returns:
      extended client context
    • createNamedQuery

      public DbStatementQuery createNamedQuery(String statementName)
      Description copied from interface: DbExecute
      Create a database query using a statement defined in the configuration file.
      Specified by:
      createNamedQuery in interface DbExecute
      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: DbExecute
      Create a database query using a statement passed as an argument.
      Specified by:
      createQuery in interface DbExecute
      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: DbExecute
      Create a database query returning a single row using a statement defined in the configuration file.
      Specified by:
      createNamedGet in interface DbExecute
      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: DbExecute
      Create a database query returning a single row using a statement passed as an argument.
      Specified by:
      createGet in interface DbExecute
      Parameters:
      statement - the query statement to be executed
      Returns:
      database statement that can process query returning a single row
    • createNamedInsert

      public DbStatementDml createNamedInsert(String statementName)
      Description copied from interface: DbExecute
      Create an insert statement using a named statement.
      Specified by:
      createNamedInsert in interface DbExecute
      Parameters:
      statementName - the name of the statement
      Returns:
      database statement that can insert data
    • createInsert

      public DbStatementDml createInsert(String statement)
      Description copied from interface: DbExecute
      Create an insert statement using a statement text.
      Specified by:
      createInsert in interface DbExecute
      Parameters:
      statement - the statement text
      Returns:
      database statement that can insert data
    • createNamedUpdate

      public DbStatementDml createNamedUpdate(String statementName)
      Description copied from interface: DbExecute
      Create an update statement using a named statement.
      Specified by:
      createNamedUpdate in interface DbExecute
      Parameters:
      statementName - the name of the statement
      Returns:
      database statement that can update data
    • createUpdate

      public DbStatementDml createUpdate(String statement)
      Description copied from interface: DbExecute
      Create an update statement using a statement text.
      Specified by:
      createUpdate in interface DbExecute
      Parameters:
      statement - the statement text
      Returns:
      database statement that can update data
    • createNamedDelete

      public DbStatementDml createNamedDelete(String statementName)
      Description copied from interface: DbExecute
      Create a delete statement using a named statement.
      Specified by:
      createNamedDelete in interface DbExecute
      Parameters:
      statementName - the name of the statement
      Returns:
      database statement that can delete data
    • createDelete

      public DbStatementDml createDelete(String statement)
      Description copied from interface: DbExecute
      Create a delete statement using a statement text.
      Specified by:
      createDelete in interface DbExecute
      Parameters:
      statement - the statement text
      Returns:
      database statement that can delete data
    • createNamedDmlStatement

      public DbStatementDml createNamedDmlStatement(String statementName)
      Description copied from interface: DbExecute
      Create a data modification statement using a statement defined in the configuration file.
      Specified by:
      createNamedDmlStatement in interface DbExecute
      Parameters:
      statementName - the name of the configuration node with statement
      Returns:
      data modification statement
    • createDmlStatement

      public DbStatementDml createDmlStatement(String statement)
      Description copied from interface: DbExecute
      Create a data modification statement using a statement passed as an argument.
      Specified by:
      createDmlStatement in interface DbExecute
      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 uses SHA-256 so 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 statement
      statement - statement that is going to be executed
      Returns:
      name of the statement