Class JDBCQueryExpression

java.lang.Object
org.castor.cpa.persistence.sql.driver.JDBCQueryExpression
All Implemented Interfaces:
QueryExpression
Direct Known Subclasses:
DB2QueryExpression, DerbyQueryExpression, HsqlQueryExpression, InformixQueryExpression, InstantDBQueryExpression, InterbaseQueryExpression, MySQLQueryExpression, OracleQueryExpression, PointbaseQueryExpression, PostgreSQLQueryExpression, ProgressQueryExpression, SapDbQueryExpression, SQLServerQueryExpression, SybaseQueryExpression

public class JDBCQueryExpression extends Object implements QueryExpression
Version:
$Revision: 8459 $ $Date: 2006-04-10 16:39:24 -0600 (Mon, 10 Apr 2006) $
Author:
Assaf Arkin
  • Field Details

  • Constructor Details

  • Method Details

    • 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(String tableName, 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(String tableName, 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(String tableName, String columnName, 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(String tableName, String columnName, String condOp, 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 String encodeColumn(String tableName, 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(String leftTable, String[] leftColumn, String leftTableAlias, String rightTable, String[] rightColumn, 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(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn, 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(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(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(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).
    • addLimitClause

      public final void addLimitClause(String limit) throws SyntaxNotSupportedException
      Description copied from interface: QueryExpression
      Adds an limit clause.
      Specified by:
      addLimitClause in interface QueryExpression
      Parameters:
      limit - The LIMIT clause to add (without the word LIMIT).
      Throws:
      SyntaxNotSupportedException - If the LIMIT clause is not supported by the RDBMS.
    • addOffsetClause

      public final void addOffsetClause(String offset) throws SyntaxNotSupportedException
      Description copied from interface: QueryExpression
      Adds an offset clause.
      Specified by:
      addOffsetClause in interface QueryExpression
      Parameters:
      offset - The OFFSET clause to add (without the word OFFSET).
      Throws:
      SyntaxNotSupportedException - If the OFFSET clause is not supported by the RDBMS.
    • getColumnList

      protected final String getColumnList()
    • addWhereClause

      protected final boolean addWhereClause(StringBuffer sql, boolean first)
    • getStatement

      public 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 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 String toString()
      Overrides:
      toString in class Object
    • clone

      public final 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 Object
    • isLimitClauseSupported

      public boolean isLimitClauseSupported()
      Provides a default implementation of QueryExpression.isLimitClauseSupported().
      Specified by:
      isLimitClauseSupported in interface QueryExpression
      Returns:
      false to indicate that this feature is not supported by default.
      See Also:
    • isOffsetClauseSupported

      public boolean isOffsetClauseSupported()
      Provides a default implementation of QueryExpression.isOffsetClauseSupported().
      Specified by:
      isOffsetClauseSupported in interface QueryExpression
      Returns:
      false to indicate that this feature is not supported by default.
      See Also: