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 DbMetaInfo
MetaInfo as acquired from the RDBMS.protected boolean
protected PersistenceFactory
protected Vector<JDBCQueryExpression.Join>
protected String
protected String
protected String
protected String
Fields 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 void
Add a column used in the query.final void
addCondition
(String tableName, String columnName, String condOp, String value) Add a condition.final void
addInnerJoin
(String leftTable, String[] leftColumn, String leftTableAlias, String rightTable, String[] rightColumn, String rightTableAlias) Add an inner join with an aliases for the tables.final void
addLimitClause
(String limit) Adds an limit clause.final void
addOffsetClause
(String offset) Adds an offset clause.final void
addOrderClause
(String order) Adds an order by clause.final void
addOuterJoin
(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn, String rightTableAlias) Add an outer join.final void
addParameter
(String tableName, String columnName, String condOp) Add a query paramater.final void
Add an entire select clause to the query with one call.final void
Add a table with an alias to the from clause.final void
addWhereClause
(String where) Adds a where clause.protected final boolean
addWhereClause
(StringBuffer sql, boolean first) final Object
clone()
Returns a clone of the query expression that can be further modified.final String
encodeColumn
(String tableName, String columnName) Encode a TableColumn for use in expressions.protected final String
protected final StringBuffer
getStandardStatement
(boolean lock, boolean oj) Helper method.getStatement
(boolean lock) Creates a SQL statement.boolean
Provides a default implementation ofQueryExpression.isLimitClauseSupported()
.boolean
Provides a default implementation ofQueryExpression.isOffsetClauseSupported()
.final void
setDbMetaInfo
(DbMetaInfo dbInfo) Store database meta information.final void
setDistinct
(boolean distinct) Set the query to be distinct.final String
toString()
-
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:
setDbMetaInfo
in interfaceQueryExpression
- 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 interfaceQueryExpression
- Parameters:
distinct
- If the query should include DISTINCT in the SQL select.
-
addColumn
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 interfaceQueryExpression
- Parameters:
tableName
- The table namecolumnName
- The column name
-
addTable
Description copied from interface:QueryExpression
Add a table with an alias to the from clause.- Specified by:
addTable
in 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:QueryExpression
Add a query paramater.- Specified by:
addParameter
in interfaceQueryExpression
- Parameters:
tableName
- The table namecolumnName
- The column namecondOp
- The conditional operation
-
addCondition
Description copied from interface:QueryExpression
Add a condition.- Specified by:
addCondition
in interfaceQueryExpression
- Parameters:
tableName
- The table namecolumnName
- The column namecondOp
- The conditional operationvalue
- The conditional value
-
encodeColumn
Description copied from interface:QueryExpression
Encode a TableColumn for use in expressions.- Specified by:
encodeColumn
in 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:QueryExpression
Add an inner join with an aliases for the tables.- Specified by:
addInnerJoin
in 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:QueryExpression
Add an outer join. May use an inner join if outer joins are not supported.- Specified by:
addOuterJoin
in 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: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 interfaceQueryExpression
- Parameters:
selectClause
- The entire sql select clause without the word SELECT
-
addWhereClause
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 interfaceQueryExpression
- Parameters:
where
- The WHERE clause to add (without the word WHERE).
-
addOrderClause
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 interfaceQueryExpression
- Parameters:
order
- The ORDER BY clause to add (without the words ORDER BY).
-
addLimitClause
Description copied from interface:QueryExpression
Adds an limit clause.- Specified by:
addLimitClause
in 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:QueryExpression
Adds an offset clause.- Specified by:
addOffsetClause
in 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:
getStatement
in 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:QueryExpression
Returns a clone of the query expression that can be further modified.- Specified by:
clone
in interfaceQueryExpression
- Overrides:
clone
in classObject
-
isLimitClauseSupported
public boolean isLimitClauseSupported()Provides a default implementation ofQueryExpression.isLimitClauseSupported()
.- Specified by:
isLimitClauseSupported
in 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:
isOffsetClauseSupported
in interfaceQueryExpression
- Returns:
- false to indicate that this feature is not supported by default.
- See Also:
-