Class DatabaseOperation<T>

  • Type Parameters:
    T - the type for this operation
    Direct Known Subclasses:
    DatabaseExecute

    public abstract class DatabaseOperation<T>
    extends java.lang.Object
    A convenience base class for build database operations
    Author:
    Xavier Witdouck
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<java.lang.Object> args
      The list of arguments for operation, if any
      private Database db
      The database this operation is associated with
      private com.d3x.core.util.Option<java.lang.Integer> fetchSize
      The result set fetch size
      private com.d3x.core.util.Option<java.lang.Integer> limit
      The max number of rows to include
      private com.d3x.core.util.Option<java.lang.String> sql
      The SQL expression for this operation
      private com.d3x.core.util.Option<java.time.Duration> timeout
      The SQL operation optional timeout
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T args​(java.lang.Object... args)
      Binds arguments to this operation
      T fetchSize​(int fetchSize)
      Sets the statement fetch size for this operation
      (package private) java.util.List<java.lang.Object> getArgs()
      The list of arguments for operation, if any
      (package private) Database getDb()
      The database this operation is associated with
      (package private) com.d3x.core.util.Option<java.lang.Integer> getFetchSize()
      The result set fetch size
      (package private) com.d3x.core.util.Option<java.lang.Integer> getLimit()
      The max number of rows to include
      (package private) com.d3x.core.util.Option<java.lang.String> getSql()
      The SQL expression for this operation
      (package private) com.d3x.core.util.Option<java.time.Duration> getTimeout()
      The SQL operation optional timeout
      T limit​(int limit)
      Sets the max number of records to include in operation
      T sql​(java.lang.String sql)
      Binds a custom SQL statement to this operation
      T timeout​(java.time.Duration timeout)
      Sets the timeout for this operation
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • db

        private Database db
        The database this operation is associated with
      • args

        private java.util.List<java.lang.Object> args
        The list of arguments for operation, if any
      • sql

        private com.d3x.core.util.Option<java.lang.String> sql
        The SQL expression for this operation
      • timeout

        private com.d3x.core.util.Option<java.time.Duration> timeout
        The SQL operation optional timeout
      • fetchSize

        private com.d3x.core.util.Option<java.lang.Integer> fetchSize
        The result set fetch size
      • limit

        private com.d3x.core.util.Option<java.lang.Integer> limit
        The max number of rows to include
    • Constructor Detail

      • DatabaseOperation

        DatabaseOperation​(Database db)
        Constructor
        Parameters:
        db - the database reference
    • Method Detail

      • sql

        public T sql​(java.lang.String sql)
        Binds a custom SQL statement to this operation
        Parameters:
        sql - the SQL statement or classpath resource to SQL statement
        Returns:
        this operation
      • args

        public T args​(java.lang.Object... args)
        Binds arguments to this operation
        Parameters:
        args - the arguments for SQL string
        Returns:
        this operation
      • timeout

        public T timeout​(java.time.Duration timeout)
        Sets the timeout for this operation
        Parameters:
        timeout - the timeout, can be null
        Returns:
        this operation
      • fetchSize

        public T fetchSize​(int fetchSize)
        Sets the statement fetch size for this operation
        Parameters:
        fetchSize - the fetch size
        Returns:
        this operation
        See Also:
        ResultSet.setFetchSize(int)
      • limit

        public T limit​(int limit)
        Sets the max number of records to include in operation
        Parameters:
        limit - the max number of records, must be > 0
        Returns:
        this operation
      • getDb

        Database getDb()
        The database this operation is associated with
      • getArgs

        java.util.List<java.lang.Object> getArgs()
        The list of arguments for operation, if any
      • getSql

        com.d3x.core.util.Option<java.lang.String> getSql()
        The SQL expression for this operation
      • getTimeout

        com.d3x.core.util.Option<java.time.Duration> getTimeout()
        The SQL operation optional timeout
      • getFetchSize

        com.d3x.core.util.Option<java.lang.Integer> getFetchSize()
        The result set fetch size
      • getLimit

        com.d3x.core.util.Option<java.lang.Integer> getLimit()
        The max number of rows to include