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
- Version:
- $Revision: 8459 $ $Date: 2006-04-10 16:39:24 -0600 (Mon, 10 Apr 2006) $
- Author:
- Assaf Arkin
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DbMetaInfoMetaInfo as acquired from the RDBMS.protected booleanprotected PersistenceFactoryprotected Vector<JDBCQueryExpression.Join> protected Stringprotected Stringprotected Stringprotected StringFields inherited from interface org.exolab.castor.persist.spi.QueryExpression
OP_BETWEEN, OP_BETWEEN_AND, OP_EQUALS, OP_GREATER, OP_GREATER_EQUALS, OP_LESS, OP_LESS_EQUALS, OP_LIKE, OP_NOT_EQUALS, OP_NOT_LIKE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidAdd a column used in the query.final voidaddCondition(String tableName, String columnName, String condOp, String value) Add a condition.final voidaddInnerJoin(String leftTable, String[] leftColumn, String leftTableAlias, String rightTable, String[] rightColumn, String rightTableAlias) Add an inner join with an aliases for the tables.final voidaddLimitClause(String limit) Adds an limit clause.final voidaddOffsetClause(String offset) Adds an offset clause.final voidaddOrderClause(String order) Adds an order by clause.final voidaddOuterJoin(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn, String rightTableAlias) Add an outer join.final voidaddParameter(String tableName, String columnName, String condOp) Add a query paramater.final voidAdd an entire select clause to the query with one call.final voidAdd a table with an alias to the from clause.final voidaddWhereClause(String where) Adds a where clause.protected final booleanaddWhereClause(StringBuffer sql, boolean first) final Objectclone()Returns a clone of the query expression that can be further modified.final StringencodeColumn(String tableName, String columnName) Encode a TableColumn for use in expressions.protected final Stringprotected final StringBuffergetStandardStatement(boolean lock, boolean oj) Helper method.getStatement(boolean lock) Creates a SQL statement.booleanProvides a default implementation ofQueryExpression.isLimitClauseSupported().booleanProvides a default implementation ofQueryExpression.isOffsetClauseSupported().final voidsetDbMetaInfo(DbMetaInfo dbInfo) Store database meta information.final voidsetDistinct(boolean distinct) Set the query to be distinct.final StringtoString()
-
Field Details
-
_tables
-
_joins
-
_select
-
_order
-
_limit
-
_offset
-
_distinct
protected boolean _distinct -
_factory
-
_dbInfo
MetaInfo as acquired from the RDBMS.
-
-
Constructor Details
-
JDBCQueryExpression
-
-
Method Details
-
setDbMetaInfo
Store database meta information.- Specified by:
setDbMetaInfoin interfaceQueryExpression- Parameters:
dbInfo- DbMetaInfo instance.
-
setDistinct
public final void setDistinct(boolean distinct) Description copied from interface:QueryExpressionSet the query to be distinct. No two rows which are the same will be returned.- Specified by:
setDistinctin interfaceQueryExpression- Parameters:
distinct- If the query should include DISTINCT in the SQL select.
-
addColumn
Description copied from interface:QueryExpressionAdd a column used in the query. Columns must be retrieved in the same order in which they were added to the query.- Specified by:
addColumnin interfaceQueryExpression- Parameters:
tableName- The table namecolumnName- The column name
-
addTable
Description copied from interface:QueryExpressionAdd a table with an alias to the from clause.- Specified by:
addTablein interfaceQueryExpression- Parameters:
tableName- The name of the table to add to the select clausetableAlias- The name of the alias under which the where clauses will access it
-
addParameter
Description copied from interface:QueryExpressionAdd a query paramater.- Specified by:
addParameterin interfaceQueryExpression- Parameters:
tableName- The table namecolumnName- The column namecondOp- The conditional operation
-
addCondition
Description copied from interface:QueryExpressionAdd a condition.- Specified by:
addConditionin interfaceQueryExpression- Parameters:
tableName- The table namecolumnName- The column namecondOp- The conditional operationvalue- The conditional value
-
encodeColumn
Description copied from interface:QueryExpressionEncode a TableColumn for use in expressions.- Specified by:
encodeColumnin interfaceQueryExpression- 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:QueryExpressionAdd an inner join with an aliases for the tables.- Specified by:
addInnerJoinin interfaceQueryExpression- Parameters:
leftTable- The table name on the left sideleftColumn- The column names on the left sideleftTableAlias- The alias name to use for the table on the left siderightTable- The table name on the right siderightColumn- The column names on the right siderightTableAlias- 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:QueryExpressionAdd an outer join. May use an inner join if outer joins are not supported.- Specified by:
addOuterJoinin interfaceQueryExpression- Parameters:
leftTable- The table name on the left sideleftColumn- The column name on the left siderightTable- The table name on the right siderightColumn- The column name on the right siderightTableAlias- The alias name to use for the table on the right side
-
addSelect
Description copied from interface:QueryExpressionAdd 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:
addSelectin interfaceQueryExpression- Parameters:
selectClause- The entire sql select clause without the word SELECT
-
addWhereClause
Description copied from interface:QueryExpressionAdds a where clause. Caller is responsible for making sure all tables mentioned in the where clause are included in the fromClause.- Specified by:
addWhereClausein interfaceQueryExpression- Parameters:
where- The WHERE clause to add (without the word WHERE).
-
addOrderClause
Description copied from interface:QueryExpressionAdds 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:
addOrderClausein interfaceQueryExpression- Parameters:
order- The ORDER BY clause to add (without the words ORDER BY).
-
addLimitClause
Description copied from interface:QueryExpressionAdds an limit clause.- Specified by:
addLimitClausein interfaceQueryExpression- Parameters:
limit- The LIMIT clause to add (without the word LIMIT).- Throws:
SyntaxNotSupportedException- If the LIMIT clause is not supported by the RDBMS.
-
addOffsetClause
Description copied from interface:QueryExpressionAdds an offset clause.- Specified by:
addOffsetClausein interfaceQueryExpression- Parameters:
offset- The OFFSET clause to add (without the word OFFSET).- Throws:
SyntaxNotSupportedException- If the OFFSET clause is not supported by the RDBMS.
-
getColumnList
-
addWhereClause
-
getStatement
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 aSyntaxNotSupportedException.- Specified by:
getStatementin interfaceQueryExpression- 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
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 tablesoj- true in the first case above, false in the second case.
-
toString
-
clone
Description copied from interface:QueryExpressionReturns a clone of the query expression that can be further modified.- Specified by:
clonein interfaceQueryExpression- Overrides:
clonein classObject
-
isLimitClauseSupported
public boolean isLimitClauseSupported()Provides a default implementation ofQueryExpression.isLimitClauseSupported().- Specified by:
isLimitClauseSupportedin interfaceQueryExpression- Returns:
- false to indicate that this feature is not supported by default.
- See Also:
-
isOffsetClauseSupported
public boolean isOffsetClauseSupported()Provides a default implementation ofQueryExpression.isOffsetClauseSupported().- Specified by:
isOffsetClauseSupportedin interfaceQueryExpression- Returns:
- false to indicate that this feature is not supported by default.
- See Also:
-