Class JDBCQueryExpression

    • Field Detail

      • _tables

        protected java.util.Hashtable<java.lang.String,​java.lang.String> _tables
      • _select

        protected java.lang.String _select
      • _order

        protected java.lang.String _order
      • _limit

        protected java.lang.String _limit
      • _offset

        protected java.lang.String _offset
      • _distinct

        protected boolean _distinct
      • _dbInfo

        protected DbMetaInfo _dbInfo
        MetaInfo as acquired from the RDBMS.
    • Constructor Detail

    • Method Detail

      • setDbMetaInfo

        public final void setDbMetaInfo​(DbMetaInfo dbInfo)
        Store database meta information.
        Specified by:
        setDbMetaInfo in interface QueryExpression
        Parameters:
        dbInfo - DbMetaInfo instance.
      • setDistinct

        public final void setDistinct​(boolean distinct)
        Description copied from interface: QueryExpression
        Set the query to be distinct. No two rows which are the same will be returned.
        Specified by:
        setDistinct in interface QueryExpression
        Parameters:
        distinct - If the query should include DISTINCT in the SQL select.
      • addColumn

        public final void addColumn​(java.lang.String tableName,
                                    java.lang.String columnName)
        Description copied from interface: QueryExpression
        Add a column used in the query. Columns must be retrieved in the same order in which they were added to the query.
        Specified by:
        addColumn in interface QueryExpression
        Parameters:
        tableName - The table name
        columnName - The column name
      • addTable

        public final void addTable​(java.lang.String tableName,
                                   java.lang.String tableAlias)
        Description copied from interface: QueryExpression
        Add a table with an alias to the from clause.
        Specified by:
        addTable in interface QueryExpression
        Parameters:
        tableName - The name of the table to add to the select clause
        tableAlias - The name of the alias under which the where clauses will access it
      • addParameter

        public final void addParameter​(java.lang.String tableName,
                                       java.lang.String columnName,
                                       java.lang.String condOp)
        Description copied from interface: QueryExpression
        Add a query paramater.
        Specified by:
        addParameter in interface QueryExpression
        Parameters:
        tableName - The table name
        columnName - The column name
        condOp - The conditional operation
      • addCondition

        public final void addCondition​(java.lang.String tableName,
                                       java.lang.String columnName,
                                       java.lang.String condOp,
                                       java.lang.String value)
        Description copied from interface: QueryExpression
        Add a condition.
        Specified by:
        addCondition in interface QueryExpression
        Parameters:
        tableName - The table name
        columnName - The column name
        condOp - The conditional operation
        value - The conditional value
      • encodeColumn

        public final java.lang.String encodeColumn​(java.lang.String tableName,
                                                   java.lang.String columnName)
        Description copied from interface: QueryExpression
        Encode a TableColumn for use in expressions.
        Specified by:
        encodeColumn in interface QueryExpression
        Parameters:
        tableName - The table name.
        columnName - The column name.
      • addInnerJoin

        public final void addInnerJoin​(java.lang.String leftTable,
                                       java.lang.String[] leftColumn,
                                       java.lang.String leftTableAlias,
                                       java.lang.String rightTable,
                                       java.lang.String[] rightColumn,
                                       java.lang.String rightTableAlias)
        Description copied from interface: QueryExpression
        Add an inner join with an aliases for the tables.
        Specified by:
        addInnerJoin in interface QueryExpression
        Parameters:
        leftTable - The table name on the left side
        leftColumn - The column names on the left side
        leftTableAlias - The alias name to use for the table on the left side
        rightTable - The table name on the right side
        rightColumn - The column names on the right side
        rightTableAlias - The alias name to use for the table on the right side
      • addOuterJoin

        public final void addOuterJoin​(java.lang.String leftTable,
                                       java.lang.String[] leftColumn,
                                       java.lang.String rightTable,
                                       java.lang.String[] rightColumn,
                                       java.lang.String rightTableAlias)
        Description copied from interface: QueryExpression
        Add an outer join. May use an inner join if outer joins are not supported.
        Specified by:
        addOuterJoin in interface QueryExpression
        Parameters:
        leftTable - The table name on the left side
        leftColumn - The column name on the left side
        rightTable - The table name on the right side
        rightColumn - The column name on the right side
        rightTableAlias - The alias name to use for the table on the right side
      • addSelect

        public final void addSelect​(java.lang.String selectClause)
        Description copied from interface: QueryExpression
        Add an entire select clause to the query with one call. The caller is responsible for making sure that all mentioned tables are included in the from clause.
        Specified by:
        addSelect in interface QueryExpression
        Parameters:
        selectClause - The entire sql select clause without the word SELECT
      • addWhereClause

        public final void addWhereClause​(java.lang.String where)
        Description copied from interface: QueryExpression
        Adds a where clause. Caller is responsible for making sure all tables mentioned in the where clause are included in the fromClause.
        Specified by:
        addWhereClause in interface QueryExpression
        Parameters:
        where - The WHERE clause to add (without the word WHERE).
      • addOrderClause

        public final void addOrderClause​(java.lang.String order)
        Description copied from interface: QueryExpression
        Adds an order by clause. Caller is responsible for making sure all tables mentioned in the order by clause are included in the fromClause.
        Specified by:
        addOrderClause in interface QueryExpression
        Parameters:
        order - The ORDER BY clause to add (without the words ORDER BY).
      • getColumnList

        protected final java.lang.String getColumnList()
      • addWhereClause

        protected final boolean addWhereClause​(java.lang.StringBuffer sql,
                                               boolean first)
      • getStatement

        public java.lang.String getStatement​(boolean lock)
                                      throws SyntaxNotSupportedException
        Creates a SQL statement. In general, for a RDBMS/JDBC driver with a full support of the SQL standard/JDBC specification, this will return a valid SQL statement. For some features, a particular RDBMS might indicate that it does not support this feature by throwing a SyntaxNotSupportedException.
        Specified by:
        getStatement in interface QueryExpression
        Parameters:
        lock - True if a write lock is required
        Returns:
        The SQL statement
        Throws:
        SyntaxNotSupportedException - If the RDBMS does not support a particular feature.
      • getStandardStatement

        protected final java.lang.StringBuffer getStandardStatement​(boolean lock,
                                                                    boolean oj)
        Helper method. Can be used in two cases: 1) for JDBC drivers which support "{oj ...OUTER JOIN ...}" notation (in accordance with JDBC specification); 2) for the databases which support "... OUTER JOIN ..." notation (in accordance with SQL-92 standard); .
        Parameters:
        lock - whether to lock selected tables
        oj - true in the first case above, false in the second case.
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • clone

        public final java.lang.Object clone()
        Description copied from interface: QueryExpression
        Returns a clone of the query expression that can be further modified.
        Specified by:
        clone in interface QueryExpression
        Overrides:
        clone in class java.lang.Object