public class JDBCQueryExpression extends Object implements QueryExpression
| Modifier and Type | Field and Description |
|---|---|
protected DbMetaInfo |
_dbInfo
MetaInfo as acquired from the RDBMS.
|
protected boolean |
_distinct |
protected PersistenceFactory |
_factory |
protected Vector<org.castor.cpa.persistence.sql.driver.JDBCQueryExpression.Join> |
_joins |
protected String |
_limit |
protected String |
_offset |
protected String |
_order |
protected String |
_select |
protected Hashtable<String,String> |
_tables |
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 and Description |
|---|
JDBCQueryExpression(PersistenceFactory factory) |
| Modifier and Type | Method and Description |
|---|---|
void |
addColumn(String tableName,
String columnName)
Add a column used in the query.
|
void |
addCondition(String tableName,
String columnName,
String condOp,
String value)
Add a condition.
|
void |
addInnerJoin(String leftTable,
String[] leftColumn,
String leftTableAlias,
String rightTable,
String[] rightColumn,
String rightTableAlias)
Add an inner join with an aliases for the tables.
|
void |
addLimitClause(String limit)
Adds an limit clause.
|
void |
addOffsetClause(String offset)
Adds an offset clause.
|
void |
addOrderClause(String order)
Adds an order by clause.
|
void |
addOuterJoin(String leftTable,
String[] leftColumn,
String rightTable,
String[] rightColumn,
String rightTableAlias)
Add an outer join.
|
void |
addParameter(String tableName,
String columnName,
String condOp)
Add a query paramater.
|
void |
addSelect(String selectClause)
Add an entire select clause to the query with one call.
|
void |
addTable(String tableName,
String tableAlias)
Add a table with an alias to the from clause.
|
void |
addWhereClause(String where)
Adds a where clause.
|
protected boolean |
addWhereClause(StringBuffer sql,
boolean first) |
Object |
clone()
Returns a clone of the query expression that can be further modified.
|
String |
encodeColumn(String tableName,
String columnName)
Encode a TableColumn for use in expressions.
|
protected String |
getColumnList() |
protected StringBuffer |
getStandardStatement(boolean lock,
boolean oj)
Helper method.
|
String |
getStatement(boolean lock)
Creates a SQL statement.
|
boolean |
isLimitClauseSupported()
Provides a default implementation of
QueryExpression.isLimitClauseSupported(). |
boolean |
isOffsetClauseSupported()
Provides a default implementation of
QueryExpression.isOffsetClauseSupported(). |
void |
setDbMetaInfo(DbMetaInfo dbInfo)
Store database meta information.
|
void |
setDistinct(boolean distinct)
Set the query to be distinct.
|
String |
toString() |
protected Vector<org.castor.cpa.persistence.sql.driver.JDBCQueryExpression.Join> _joins
protected String _select
protected String _order
protected String _limit
protected String _offset
protected boolean _distinct
protected PersistenceFactory _factory
protected DbMetaInfo _dbInfo
public JDBCQueryExpression(PersistenceFactory factory)
public final void setDbMetaInfo(DbMetaInfo dbInfo)
setDbMetaInfo in interface QueryExpressiondbInfo - DbMetaInfo instance.public final void setDistinct(boolean distinct)
QueryExpressionsetDistinct in interface QueryExpressiondistinct - If the query should include DISTINCT in the SQL select.public final void addColumn(String tableName, String columnName)
QueryExpressionaddColumn in interface QueryExpressiontableName - The table namecolumnName - The column namepublic final void addTable(String tableName, String tableAlias)
QueryExpressionaddTable in interface QueryExpressiontableName - The name of the table to add to the select clausetableAlias - The name of the alias under which the where clauses will access itpublic final void addParameter(String tableName, String columnName, String condOp)
QueryExpressionaddParameter in interface QueryExpressiontableName - The table namecolumnName - The column namecondOp - The conditional operationpublic final void addCondition(String tableName, String columnName, String condOp, String value)
QueryExpressionaddCondition in interface QueryExpressiontableName - The table namecolumnName - The column namecondOp - The conditional operationvalue - The conditional valuepublic final String encodeColumn(String tableName, String columnName)
QueryExpressionencodeColumn in interface QueryExpressiontableName - The table name.columnName - The column name.public final void addInnerJoin(String leftTable, String[] leftColumn, String leftTableAlias, String rightTable, String[] rightColumn, String rightTableAlias)
QueryExpressionaddInnerJoin in interface QueryExpressionleftTable - 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 sidepublic final void addOuterJoin(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn, String rightTableAlias)
QueryExpressionaddOuterJoin in interface QueryExpressionleftTable - 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 sidepublic final void addSelect(String selectClause)
QueryExpressionaddSelect in interface QueryExpressionselectClause - The entire sql select clause without the word SELECTpublic final void addWhereClause(String where)
QueryExpressionaddWhereClause in interface QueryExpressionwhere - The WHERE clause to add (without the word WHERE).public final void addOrderClause(String order)
QueryExpressionaddOrderClause in interface QueryExpressionorder - The ORDER BY clause to add (without the words ORDER BY).public final void addLimitClause(String limit) throws SyntaxNotSupportedException
QueryExpressionaddLimitClause in interface QueryExpressionlimit - The LIMIT clause to add (without the word LIMIT).SyntaxNotSupportedException - If the LIMIT clause is not supported by the RDBMS.public final void addOffsetClause(String offset) throws SyntaxNotSupportedException
QueryExpressionaddOffsetClause in interface QueryExpressionoffset - The OFFSET clause to add (without the word OFFSET).SyntaxNotSupportedException - If the OFFSET clause is not supported by the RDBMS.protected final String getColumnList()
protected final boolean addWhereClause(StringBuffer sql, boolean first)
public String getStatement(boolean lock) throws SyntaxNotSupportedException
SyntaxNotSupportedException.getStatement in interface QueryExpressionlock - True if a write lock is requiredSyntaxNotSupportedException - If the RDBMS does not support a particular feature.protected final StringBuffer getStandardStatement(boolean lock, boolean oj)
lock - whether to lock selected tablesoj - true in the first case above, false in the second case.public final Object clone()
QueryExpressionclone in interface QueryExpressionclone in class Objectpublic boolean isLimitClauseSupported()
QueryExpression.isLimitClauseSupported().isLimitClauseSupported in interface QueryExpressionQueryExpression.isLimitClauseSupported()public boolean isOffsetClauseSupported()
QueryExpression.isOffsetClauseSupported().isOffsetClauseSupported in interface QueryExpressionQueryExpression.isOffsetClauseSupported()Copyright © 2014. All rights reserved.