org.exolab.castor.persist.spi

Interface QueryExpression

public interface QueryExpression

Defines the interface for a query expression. The query expression object is used to construct queries including parameters, conditions and joins, and generates the SQL statement for the underlying database.

A query experession object is created for each unique query, populated with the query parameters and the SQL statement is obtained from it at the proper time.

A query expression is generated from {@link PersistenceFactory}, see this interface for information on how to configure it. The operators defined in this interface are part of SQL 92 and the supported OQL syntax and are expected to be supported by all query expressions.

Version: $Revision: 1.1.1.1 $ $Date: 2003/03/03 07:08:52 $

Author: Assaf Arkin

Field Summary
StringOpBetween
Between operator.
StringOpBetweenAnd
Between and operator.
StringOpEquals
Equality operator.
StringOpGreater
Greater then operator.
StringOpGreaterEquals
Greater then or equals operator.
StringOpLess
Less then operator.
StringOpLessEquals
Less then or equals operator.
StringOpLike
Like operator.
StringOpNotEquals
Inequality operator.
StringOpNotLike
Not like operator.
Method Summary
voidaddColumn(String tableName, String columnName)
Add a column used in the query.
voidaddCondition(String tableName, String columnName, String condOp, String value)
Add a condition.
voidaddInnerJoin(String leftTable, String leftColumn, String rightTable, String rightColumn)
Add an inner join.
voidaddInnerJoin(String leftTable, String leftColumn, String leftTableAlias, String rightTable, String rightColumn, String rightTableAlias)
Add an inner join with an aliases for the tables
voidaddInnerJoin(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn)
Add an inner join
voidaddInnerJoin(String leftTable, String[] leftColumn, String leftTableAlias, String rightTable, String[] rightColumn, String rightTableAlias)
Add an inner join with an aliases for the tables
voidaddLimitClause(String limitClause)
Adds an limit clause.
voidaddOrderClause(String orderClause)
Adds an order by clause.
voidaddOuterJoin(String leftTable, String leftColumn, String rightTable, String rightColumn)
Add an outer join.
voidaddOuterJoin(String leftTable, String leftColumn, String rightTable, String rightColumn, String rightTableAlias)
Add an outer join.
voidaddOuterJoin(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn)
voidaddOuterJoin(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn, String rightTableAlias)
voidaddParameter(String tableName, String columnName, String condOp)
Add a query paramater.
voidaddSelect(String selectClause)
Add an entire select clause to the query with one call.
voidaddTable(String tableName)
Add a table to the from clause.
voidaddTable(String tableName, String tableAlias)
Add a table with an alias to the from clause.
voidaddWhereClause(String whereClause)
Adds a where clause.
Objectclone()
Returns a clone of the query expression that can be further modified.
StringencodeColumn(String tableName, String columnName)
Encode a TableColumn for use in expressions
StringgetStatement(boolean writeLock)
Return the query expression as an SQL statement.
voidsetDistinct(boolean distinct)
Set the query to be distinct.

Field Detail

OpBetween

public String OpBetween
Between operator. (BETWEEN)

See Also: OpBetweenAnd

OpBetweenAnd

public String OpBetweenAnd
Between and operator. (AND)

See Also: OpBetween

OpEquals

public String OpEquals
Equality operator. (=)

OpGreater

public String OpGreater
Greater then operator. (>)

OpGreaterEquals

public String OpGreaterEquals
Greater then or equals operator. (>=)

OpLess

public String OpLess
Less then operator. (<)

OpLessEquals

public String OpLessEquals
Less then or equals operator. (<=)

OpLike

public String OpLike
Like operator. (LIKE)

OpNotEquals

public String OpNotEquals
Inequality operator. (<>)

OpNotLike

public String OpNotLike
Not like operator. (NOT LIKE)

Method Detail

addColumn

public void addColumn(String tableName, String columnName)
Add a column used in the query. Columns must be retrieved in the same order in which they were added to the query.

Parameters: tableName The table name columnName The column name

addCondition

public void addCondition(String tableName, String columnName, String condOp, String value)
Add a condition.

Parameters: tableName The table name columnName The column name condOp The conditional operation value The conditional value

addInnerJoin

public void addInnerJoin(String leftTable, String leftColumn, String rightTable, String rightColumn)
Add an inner join.

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

addInnerJoin

public void addInnerJoin(String leftTable, String leftColumn, String leftTableAlias, String rightTable, String rightColumn, String rightTableAlias)
Add an inner join with an aliases for the tables

Parameters: leftTable The table name on the left side leftColumn The column name 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 name on the right side rightTableAlias The alias name to use for the table on the right side

addInnerJoin

public void addInnerJoin(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn)
Add an inner join

Parameters: leftTable The table name on the left side leftColumn The column names on the left side rightTable The table name on the right side rightColumn The column names on the right side

addInnerJoin

public void addInnerJoin(String leftTable, String[] leftColumn, String leftTableAlias, String rightTable, String[] rightColumn, String rightTableAlias)
Add an inner join with an aliases for the tables

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

addLimitClause

public void addLimitClause(String limitClause)
Adds an limit clause.

Parameters: limitClause The LIMIT clause to add (without the word LIMIT).

addOrderClause

public void addOrderClause(String orderClause)
Adds an order by clause. Caller is responsible for making sure all tables mentioned in the order by clause are included in the fromClause.

Parameters: orderClause The ORDER BY clause to add (without the words ORDER BY).

addOuterJoin

public void addOuterJoin(String leftTable, String leftColumn, String rightTable, String rightColumn)
Add an outer join. May use an inner join if outer joins are not supported.

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

addOuterJoin

public void addOuterJoin(String leftTable, String leftColumn, String rightTable, String rightColumn, String rightTableAlias)
Add an outer join. May use an inner join if outer joins are not supported.

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

addOuterJoin

public void addOuterJoin(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn)

addOuterJoin

public void addOuterJoin(String leftTable, String[] leftColumn, String rightTable, String[] rightColumn, String rightTableAlias)

addParameter

public void addParameter(String tableName, String columnName, String condOp)
Add a query paramater.

Parameters: tableName The table name columnName The column name condOp The conditional operation

addSelect

public void addSelect(String selectClause)
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.

Parameters: selectClause The entire sql select clause without the word SELECT

addTable

public void addTable(String tableName)
Add a table to the from clause.

Parameters: tableName The name of the table to add to the select clause

addTable

public void addTable(String tableName, String tableAlias)
Add a table with an alias to the from clause.

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

addWhereClause

public void addWhereClause(String whereClause)
Adds a where clause. Caller is responsible for making sure all tables mentioned in the where clause are included in the fromClause.

Parameters: whereClause The WHERE clause to add (without the word WHERE).

clone

public Object clone()
Returns a clone of the query expression that can be further modified.

encodeColumn

public String encodeColumn(String tableName, String columnName)
Encode a TableColumn for use in expressions

Parameters: tableName The table name columnName The column name

getStatement

public String getStatement(boolean writeLock)
Return the query expression as an SQL statement. The resulting SQL is fed directly to a JDBC statement. writeLock is true if the query must obtain a write lock on the queried table.

Parameters: writeLock True if a write lock is required

Returns: The SQL statement

Throws: QueryException The query cannot be constructed for this engine

setDistinct

public void setDistinct(boolean distinct)
Set the query to be distinct. No two rows which are the same will be returned.

Parameters: distinct If the query should include DISTINCT in the SQL select.

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