Class AbstractBatcher

    • Field Detail

      • logSql

        protected static final org.slf4j.Logger logSql
        Log all SQL statements.
      • debugSqlEnabled

        protected static final boolean debugSqlEnabled
        So we don't always have to call logSql.debug()
      • dc

        private WeakReference<DbControl> dc
        A reference to the current DbControl object. We use a WeakReference since we it is always the client applications responsibility to keep control over the DbControl object.
      • batchSize

        private int batchSize
        SQL command batch size.
    • Constructor Detail

      • AbstractBatcher

        AbstractBatcher()
        Constructor for a batcher.
        Throws:
        BaseException - If there is an error
    • Method Detail

      • getBatchSize

        public int getBatchSize()
        Description copied from interface: Batcher
        Get the current batch size of the batcher. The batch size indicates how many individual items a batcher is caching in memory before they are automatically flushed to the database.
        Specified by:
        getBatchSize in interface Batcher
        Returns:
        The current batch size, or 0 if automatic flushing is turned of
      • setBatchSize

        public void setBatchSize​(int batchSize)
        Description copied from interface: Batcher
        Sets the batch size. The batch size indicates how many individual items a batcher is caching in memory before they are automatically flushed to the database.
        Specified by:
        setBatchSize in interface Batcher
        Parameters:
        batchSize - Size of the batch, or 0 to disable automatic flushing
      • isClosed

        public final boolean isClosed()
        Check if this batcher is closed or not. The batcher is considered as closed when it isn't attached to a DbControl or if the DbControl it is attached to has been closed.
        Specified by:
        isClosed in interface Batcher
        Returns:
        TRUE if the batcher is closed, FALSE otherwise
        See Also:
        Batcher.close()
      • close

        public final void close()
                         throws BaseException
        Description copied from interface: Batcher
        Flush the batcher and close it. A closed batcher will not accept any more data for insert, update or delete. Note! A batcher that uses an underlying DbControl to connect to the database will automatically be closed when the DbControl is closed.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Batcher
        Throws:
        BaseException - If there is an error
        See Also:
        Batcher.isClosed(), Batcher.flush()
      • updateLastAccess

        void updateLastAccess()
        Update the last access time so the session control doesn't get cleaned up.
      • setDbControl

        protected final void setDbControl​(DbControl dc)
        Set the DbControl that is controlling this batcher. This method MUST be called by all subclasses after successful construction of a batcher. This method also registers the batcher with the DbControl using DbControl.addBatcher(Batcher)
        Since:
        2.4.2
      • onBeforeClose

        void onBeforeClose()
                    throws BaseException
        Let a subclass cleanup itself before the connection to the database is closed. This method is called by the close() method after Batcher.flush() has been called but before the connection to the database is lost. Typical use of this method is to update properties on parent object (for example, spot count) and to close open SQL statements.
        Throws:
        BaseException