org.exolab.castor.jdo.drivers

Class JDBCQueryExpression

Implemented Interfaces:
QueryExpression
Known Direct Subclasses:
DB2QueryExpression, DerbyQueryExpression, HsqlQueryExpression, InformixQueryExpression, InstantDBQueryExpression, InterbaseQueryExpression, MySQLQueryExpression, OracleQueryExpression, PointbaseQueryExpression, PostgreSQLQueryExpression, ProgressQueryExpression, SapDbQueryExpression, SQLServerQueryExpression, SybaseQueryExpression

public class JDBCQueryExpression
extends java.lang.Object
implements QueryExpression

Version:
$Revision: 7127 $ $Date: 2006-04-10 16:39:24 -0600 (Mon, 10 Apr 2006) $
Author:
Assaf Arkin

Nested Class Summary

(package private) static class
JDBCQueryExpression.Join

Field Summary

protected DbMetaInfo
_dbInfo
MetaInfo as acquired from the RDBMS.
protected boolean
_distinct
protected PersistenceFactory
_factory
protected Vector
_joins
protected String
_limit
protected String
_offset
protected String
_order
protected String
_select
protected Hashtable
_tables

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

JDBCQueryExpression(PersistenceFactory factory)

Method Summary

void
addColumn(String tableName, String columnName)
void
addCondition(String tableName, String columnName, String condOp, String value)
void
addInnerJoin(String leftTable, String leftColumn, String rightTable, String rightColumn)
void
addInnerJoin(String leftTable, String leftColumn, String leftTableAlias, String rightTable, String rightColumn, String rightTableAlias)
void
addInnerJoin(String leftTable, String[] leftColumn, String leftTableAlias, String rightTable, String[] rightColumn, String rightTableAlias)
void
addInnerJoin(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn)
void
addLimitClause(String limit)
void
addOffsetClause(String offset)
void
addOrderClause(String order)
void
addOuterJoin(String leftTable, String leftColumn, String rightTable, String rightColumn)
void
addOuterJoin(String leftTable, String leftColumn, String rightTable, String rightColumn, String rightTableAlias)
void
addOuterJoin(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn)
void
addOuterJoin(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn, String rightTableAlias)
void
addParameter(String tableName, String columnName, String condOp)
void
addSelect(String selectClause)
void
addTable(String tableName)
void
addTable(String tableName, String tableAlias)
void
addWhereClause(String where)
protected boolean
addWhereClause(StringBuffer sql, boolean first)
Object
clone()
String
encodeColumn(String tableName, String columnName)
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)
String
toString()

Field Details

_dbInfo

protected DbMetaInfo _dbInfo
MetaInfo as acquired from the RDBMS.

_distinct

protected boolean _distinct

_factory

protected PersistenceFactory _factory

_joins

protected Vector _joins

_limit

protected String _limit

_offset

protected String _offset

_order

protected String _order

_select

protected String _select

_tables

protected Hashtable _tables

Constructor Details

JDBCQueryExpression

public JDBCQueryExpression(PersistenceFactory factory)

Method Details

addColumn

public void addColumn(String tableName,
                      String columnName)
Specified by:
addColumn in interface QueryExpression

addCondition

public void addCondition(String tableName,
                         String columnName,
                         String condOp,
                         String value)
Specified by:
addCondition in interface QueryExpression

addInnerJoin

public void addInnerJoin(String leftTable,
                         String leftColumn,
                         String rightTable,
                         String rightColumn)
Specified by:
addInnerJoin in interface QueryExpression

addInnerJoin

public void addInnerJoin(String leftTable,
                         String leftColumn,
                         String leftTableAlias,
                         String rightTable,
                         String rightColumn,
                         String rightTableAlias)
Specified by:
addInnerJoin in interface QueryExpression

addInnerJoin

public void addInnerJoin(String leftTable,
                         String[] leftColumn,
                         String leftTableAlias,
                         String rightTable,
                         String[] rightColumn,
                         String rightTableAlias)
Specified by:
addInnerJoin in interface QueryExpression

addInnerJoin

public void addInnerJoin(String leftTable,
                         String[] leftColumn,
                         String rightTable,
                         String[] rightColumn)
Specified by:
addInnerJoin in interface QueryExpression

addLimitClause

public void addLimitClause(String limit)
            throws SyntaxNotSupportedException
Specified by:
addLimitClause in interface QueryExpression

addOffsetClause

public void addOffsetClause(String offset)
            throws SyntaxNotSupportedException
Specified by:
addOffsetClause in interface QueryExpression

addOrderClause

public void addOrderClause(String order)
Specified by:
addOrderClause in interface QueryExpression

addOuterJoin

public void addOuterJoin(String leftTable,
                         String leftColumn,
                         String rightTable,
                         String rightColumn)
Specified by:
addOuterJoin in interface QueryExpression

addOuterJoin

public void addOuterJoin(String leftTable,
                         String leftColumn,
                         String rightTable,
                         String rightColumn,
                         String rightTableAlias)
Specified by:
addOuterJoin in interface QueryExpression

addOuterJoin

public void addOuterJoin(String leftTable,
                         String[] leftColumn,
                         String rightTable,
                         String[] rightColumn)
Specified by:
addOuterJoin in interface QueryExpression

addOuterJoin

public void addOuterJoin(String leftTable,
                         String[] leftColumn,
                         String rightTable,
                         String[] rightColumn,
                         String rightTableAlias)
Specified by:
addOuterJoin in interface QueryExpression

addParameter

public void addParameter(String tableName,
                         String columnName,
                         String condOp)
Specified by:
addParameter in interface QueryExpression

addSelect

public void addSelect(String selectClause)
Specified by:
addSelect in interface QueryExpression

addTable

public void addTable(String tableName)
Specified by:
addTable in interface QueryExpression

addTable

public void addTable(String tableName,
                     String tableAlias)
Specified by:
addTable in interface QueryExpression

addWhereClause

public void addWhereClause(String where)
Specified by:
addWhereClause in interface QueryExpression

addWhereClause

protected boolean addWhereClause(StringBuffer sql,
                                 boolean first)

clone

public Object clone()
Specified by:
clone in interface QueryExpression

encodeColumn

public String encodeColumn(String tableName,
                           String columnName)
Specified by:
encodeColumn in interface QueryExpression

getColumnList

protected String getColumnList()

getStandardStatement

protected 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.

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
Throws:
SyntaxNotSupportedException - If the RDBMS does not support a particular feature.

isLimitClauseSupported

public boolean isLimitClauseSupported()
Specified by:
isLimitClauseSupported in interface QueryExpression
Returns:
false to indicate that this feature is not supported by default.

isOffsetClauseSupported

public boolean isOffsetClauseSupported()
Specified by:
isOffsetClauseSupported in interface QueryExpression
Returns:
false to indicate that this feature is not supported by default.

setDbMetaInfo

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

setDistinct

public void setDistinct(boolean distinct)
Specified by:
setDistinct in interface QueryExpression

toString

public String toString()

Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com