Class AbstractBatchImpl

  • All Implemented Interfaces:
    Batch
    Direct Known Subclasses:
    BatchingBatch, NonBatchingBatch

    public abstract class AbstractBatchImpl
    extends Object
    implements Batch
    Convenience base class for implementers of the Batch interface.
    • Method Detail

      • doExecuteBatch

        protected abstract void doExecuteBatch()
        Perform batch execution..

        This is called from the explicit execution, but may also be called from elsewhere depending on the exact implementation.

      • sqlExceptionHelper

        protected SqlExceptionHelper sqlExceptionHelper()
        Convenience access to the SQLException helper.
        Returns:
        The underlying SQLException helper.
      • sqlStatementLogger

        protected SqlStatementLogger sqlStatementLogger()
        Convenience access to the SQL statement logger.
        Returns:
        The underlying JDBC services.
      • abortBatch

        protected void abortBatch​(Exception cause)
      • getStatements

        protected LinkedHashMap<String,​PreparedStatement> getStatements()
        Access to the batch's map of statements (keyed by SQL statement string).
        Returns:
        This batch's statements.
      • getKey

        public final BatchKey getKey()
        Description copied from interface: Batch
        Retrieves the object being used to key (uniquely identify) this batch.
        Specified by:
        getKey in interface Batch
        Returns:
        The batch key.
      • addObserver

        public void addObserver​(BatchObserver observer)
        Description copied from interface: Batch
        Adds an observer to this batch.
        Specified by:
        addObserver in interface Batch
        Parameters:
        observer - The batch observer.
      • getBatchStatement

        public PreparedStatement getBatchStatement​(String sql,
                                                   boolean callable)
        Description copied from interface: Batch
        Get a statement which is part of the batch, creating if necessary (and storing for next time).
        Specified by:
        getBatchStatement in interface Batch
        Parameters:
        sql - The SQL statement.
        callable - Is the SQL statement callable?
        Returns:
        The prepared statement instance, representing the SQL statement.
      • execute

        public final void execute()
        Description copied from interface: Batch
        Execute this batch.
        Specified by:
        execute in interface Batch
      • releaseStatements

        protected void releaseStatements()
      • notifyObserversExplicitExecution

        protected final void notifyObserversExplicitExecution()
        Convenience method to notify registered observers of an explicit execution of this batch.
      • notifyObserversImplicitExecution

        protected final void notifyObserversImplicitExecution()
        Convenience method to notify registered observers of an implicit execution of this batch.
      • release

        public void release()
        Description copied from interface: Batch
        Used to indicate that the batch instance is no longer needed and that, therefore, it can release its resources.
        Specified by:
        release in interface Batch