Class DBContextBase

java.lang.Object
org.apache.empire.db.context.DBContextBase
All Implemented Interfaces:
DBContext
Direct Known Subclasses:
DBContextStatic

public abstract class DBContextBase extends Object implements DBContext
DBContextBase Basic implementation of the DBContext interface which can be used as a base class for own implmentations
Author:
rainer
  • Constructor Details

    • DBContextBase

      public DBContextBase()
  • Method Details

    • createUtils

      protected DBUtils createUtils()
      Factory function for Utils creation
      Returns:
      the utils implementation
    • setUtils

      protected void setUtils(DBUtils utils)
    • getUtils

      public DBUtils getUtils()
      Specified by:
      getUtils in interface DBContext
    • getConnection

      protected abstract Connection getConnection(boolean required)
    • getRollbackManager

      protected abstract DBRollbackManager getRollbackManager(boolean required)
    • getConnection

      public Connection getConnection()
      Specified by:
      getConnection in interface DBContext
    • isPreparedStatementsEnabled

      public abstract boolean isPreparedStatementsEnabled()
      returns whether DBCommmand should automatically create a prepared statement with command params (?) Event if this is false, is still possible to manually add command params using cmd.addCmdParam();
      Returns:
      true if automatic prepared Statements are enabled or false if not
    • createCommand

      public final DBCommand createCommand()
      Creates a new Command object for the given database
      Specified by:
      createCommand in interface DBContext
      Returns:
      the command object.
    • executeSQL

      public final int executeSQL(String sqlCmd, Object[] sqlParams)
      Executes an SQLStatment
      Specified by:
      executeSQL in interface DBContext
      Parameters:
      sqlCmd - the SQL-Command
      sqlParams - a list of objects to replace sql parameters
    • executeInsert

      public final int executeInsert(DBCommand cmd)
      Executes an Insert statement from a command object
      Specified by:
      executeInsert in interface DBContext
      Parameters:
      cmd - the command object containing the insert command
      Returns:
      the number of records that have been inserted with the supplied statement
    • executeInsertInto

      public final int executeInsertInto(DBTable table, DBCommand cmd)
      Executes an InsertInfo statement from a command object
      Specified by:
      executeInsertInto in interface DBContext
      Parameters:
      table - the table into which to insert the selected data
      cmd - the command object containing the selection command
      Returns:
      the number of records that have been inserted with the supplied statement
    • executeUpdate

      public final int executeUpdate(DBCommand cmd)
      Executes an Update statement from a command object
      Specified by:
      executeUpdate in interface DBContext
      Parameters:
      cmd - the command object containing the update command
      Returns:
      the number of records that have been updated with the supplied statement
    • executeDelete

      public final int executeDelete(DBTable from, DBCommand cmd)
      Executes a Delete statement from a command object
      Specified by:
      executeDelete in interface DBContext
      Parameters:
      from - the database table from which to delete records
      cmd - the command object containing the delete constraints
      Returns:
      the number of records that have been deleted with the supplied statement
    • commit

      public void commit()
      Specified by:
      commit in interface DBContext
    • rollback

      public void rollback()
      Discards all changes made since the previous commit/rollback and releases any database locks currently held by this Connection.
      Specified by:
      rollback in interface DBContext
    • appendRollbackHandler

      public void appendRollbackHandler(DBRollbackHandler handler)
      Specified by:
      appendRollbackHandler in interface DBContext
    • removeRollbackHandler

      public void removeRollbackHandler(DBObject object)
      Specified by:
      removeRollbackHandler in interface DBContext
    • discard

      public void discard()
      Discard connection releated ressources WARING: No gurarantee it will be called
      Specified by:
      discard in interface DBContext
    • closeConnection

      protected void closeConnection()
      helper to close a connection on discard