org.jpox.store.query
Class QueryStatement

java.lang.Object
  extended byorg.jpox.store.query.QueryStatement
All Implemented Interfaces:
QueryExpression
Direct Known Subclasses:
Oracle99QueryStatement, OracleQueryStatement, SAPDBQueryStatement

public class QueryStatement
extends java.lang.Object
implements QueryExpression

Representation of a statement for a Query. Provides methods to specify joins to other tables and to select columns from these tables. Provides methods to apply restrictions on the result. The resultant statement consists of a SELECT clause, a FROM clause and a WHERE clause. Provides output as either a SELECT statement or as a DELETE statement. The DELETE form of the statement uses just the FROM and WHERE clauses.

Version:
$Revision: 1.55 $

Nested Class Summary
static class QueryStatement.Join
          A join in a query.
 
Field Summary
protected  java.util.List crossJoins
          add tables/crossJoin but no joins to they, will be output as FROM TABLE1,TABLE2,TABLE3
protected  DatastoreAdapter dba
           
protected  DatastoreIdentifier defaultRangeVar
           
protected  boolean distinctResults
           
protected  java.util.List groupingExpressions
          User-provided expressions for GROUP BY clause.
protected  boolean hasAggregateExpression
          whether there is an aggregate expression present in the select
protected  BooleanExpression havingExpr
          Expression for any HAVING clause.
protected  LogicSetExpression initialTableExpr
           
protected  boolean isExistsSubQuery
          Whether this query is to be used as a as set for the Exists function.
protected  java.util.List joins
          inner/left/right joins
protected  java.util.List joinsTo
          ensures that we don't have duplicate JOINs From vs To
protected static Localiser LOCALISER
          Localisation for messages.
protected  boolean[] orderingDirections
          Directions for any ORDER BY expressions (1 for each orderingExpressions entry).
protected  ScalarExpression[] orderingExpressions
          Expressions for any ORDER BY clause.
protected  long rangeCount
          The number of records to be retrieved in any range restriction.
protected  long rangeOffset
          The offset for any range restriction.
protected  java.util.List selected
          projected in columns
protected  char stmtJoinsSeparator
          Separate joins e.g.
protected  StatementText stmtText
          Statement text for this Query Statement.
protected  StoreManager storeMgr
           
protected  java.util.Map tableExprsByRangeVar
           
protected  java.util.List union
          union to many QueryExpressions
protected  boolean useInnerJoinsOnly
          Flag to allow overriding of the default join type applied by JPOX.
protected  BooleanExpression whereExpr
          filter condition
 
Constructor Summary
QueryStatement(DatastoreContainerObject initialTable, ClassLoaderResolver clr)
          Constructor.
QueryStatement(DatastoreContainerObject initialTable, DatastoreIdentifier initialRangeVar, ClassLoaderResolver clr)
          Constructor.
 
Method Summary
 void addGroupingExpression(ScalarExpression expr)
          Method to add a grouping expression to the query.
protected  void addOrderingColumnsToSelect()
          Convenience method to add any necessary columns to the SELECT that are needed by the ordering constraint.
 void andCondition(BooleanExpression condition)
          Method to add an additional WHERE clause to the query.
 void andCondition(BooleanExpression condition, boolean unionQueries)
          add an condition to the query and queries involved in the union if unionQuery is true
protected  void assertNotFrozen()
           
 void crossJoin(LogicSetExpression tableExpr, boolean unionQueries)
          Method to add tables/alias but no joins to they, will be output as FROM TABLE1,TABLE2,TABLE3
protected  StatementText generateOrderingStatement()
          Convenience method to generate the ordering statement to add to the overall query statement.
 ClassLoaderResolver getClassLoaderResolver()
          Accessor for the class-loader resolver.
 LogicSetExpression getDefaultTableExpression()
          Accessor for the main table for this query statement.
 boolean getDistinctResults()
          Accessor for whether this query will return distinct results.
 ScalarExpression[] getGroupingExpressions()
          Accessor for the grouping expressions (if any).
 BooleanExpression getHavingExpression()
          Accessor for the having expression (if any).
 LogicSetExpression getInitialTableExpr()
          Accessor for the main table of this statement.
 int getNumberOfScalarExpressions()
          Accessor for the number of ScalarExpression projected.
 ScalarExpression[] getOrderingExpressions()
          Accessor for the ordering expressions (if any).
 StoreManager getStoreManager()
          Accessor for the Store Manager.
 LogicSetExpression getTableExpression(DatastoreIdentifier rangeVar)
          Accessor for the table with the specified "alias".
 boolean getUseInnerJoinsOnly()
          Accessor for whether to only use inner joins.
 boolean hasCrossJoin(LogicSetExpression tableExpr)
          Method to add tables/alias but no joins to they, will be output as FROM TABLE1,TABLE2,TABLE3
 boolean hasMetaDataExpression()
          Whether this query will return a meta data expression (containing JPOXMETADATA).
 void innerJoin(ScalarExpression expr, ScalarExpression expr2, LogicSetExpression tblExpr, boolean equals)
          Method to do an inner join to another table.
 void innerJoin(ScalarExpression expr, ScalarExpression expr2, LogicSetExpression tblExpr, boolean equals, boolean unionQueries)
          Method to do an inner join to another table, and optionally apply it to any unions for this query.
 void iorCondition(BooleanExpression condition)
          Method to add an IOR condition to the WHERE clause of the statement.
 void iorCondition(BooleanExpression condition, boolean unionQueries)
          add an condition to the query and queries involved in the union if unionQuery is true
 void join(ScalarExpression expr1, ScalarExpression expr2, LogicSetExpression tblExpr, int joinType, boolean equals)
          Method to do a join to another table.
 void join(ScalarExpression expr1, ScalarExpression expr2, LogicSetExpression tblExpr, int joinType, boolean equals, boolean unionQueries)
          Method to add a join to another table.
 void leftOuterJoin(ScalarExpression expr, ScalarExpression expr2, LogicSetExpression tblExpr, boolean equals)
          Method to do a left outer join to another table.
 void leftOuterJoin(ScalarExpression expr, ScalarExpression expr2, LogicSetExpression tblExpr, boolean equals, boolean unionQueries)
          Method to do a left outer join to another table, and optionally apply it to any unions for this query.
 LogicSetExpression newTableExpression(DatastoreContainerObject mainTable, DatastoreIdentifier rangeVar)
          Creates a table expression
 LogicSetExpression[] newTableExpression(DatastoreContainerObject mainTable, DatastoreIdentifier rangeVar, boolean unionQueries)
          Creates a table expression
 void reset()
          Resets the compiled expression statement.
 void rightOuterJoin(ScalarExpression expr, ScalarExpression expr2, LogicSetExpression tblExpr, boolean equals)
          Method to do a right outer join to another table.
 void rightOuterJoin(ScalarExpression expr, ScalarExpression expr2, LogicSetExpression tblExpr, boolean equals, boolean unionQueries)
          Method to do a right outer join to another table, and optionally apply it to any unions for this query.
 int[] select(DatastoreIdentifier rangeVar, JavaTypeMapping mapping)
          Select columns of the specified mapping for the table identifier.
 int[] select(DatastoreIdentifier rangeVar, JavaTypeMapping mapping, boolean unionQueries)
          select columns, add to union queries, if unionQueries is true
 int[] select(JavaTypeMapping mapping)
          Select the columns for a mapping.
 int[] select(JavaTypeMapping mapping, boolean unionQueries)
          select a new column, add to union queries, if unionQueries is true
 int[] selectDatastoreIdentity(java.lang.String alias, boolean unionQueries)
          Select the datastore identity of the primary table of the query.
 int[] selectField(java.lang.String fieldName, java.lang.String alias, boolean unionQueries)
          Select the column(s) for the specified field of the primary table of the query.
 int selectScalarExpression(ScalarExpression expr)
          Select an expression.
 int selectScalarExpression(ScalarExpression expr, boolean unionQueries)
          Select an expression.
 int[] selectVersion(java.lang.String alias)
          Select the version column of the primary table of the query.
 int[] selectVersion(java.lang.String alias, boolean unionQueries)
          Select the version column of the primary table of the query.
 void setDistinctResults(boolean distinctResults)
          Mutator for whether the query returns distinct results.
 void setExistsSubQuery(boolean isExistsSubQuery)
          Set this query is to be used as a set for the Exists function.
 void setHaving(BooleanExpression expr)
          Mutator for the "having" expression.
 void setOrdering(ScalarExpression[] exprs, boolean[] descending)
          Mutator for the ordering criteria.
 void setRangeConstraint(long offset, long count)
          Method to add a range constraint on any SELECT.
 void setUseInnerJoinsOnly(boolean innerJoins)
          Mutator for whether to use only inner joins.
 StatementText toDeleteStatementText()
          Method to convert the criteria into a delete statement text.
 StatementText toStatementText(boolean lock)
          Method to convert the criteria into the statement text.
 java.lang.String toString()
           
 java.lang.String toString(boolean lock)
          Stringifier
 void union(QueryExpression expr)
          Method to union this query statement with another query statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localisation for messages.


storeMgr

protected final StoreManager storeMgr

dba

protected final DatastoreAdapter dba

defaultRangeVar

protected final DatastoreIdentifier defaultRangeVar

initialTableExpr

protected final LogicSetExpression initialTableExpr

tableExprsByRangeVar

protected java.util.Map tableExprsByRangeVar

distinctResults

protected boolean distinctResults

selected

protected java.util.List selected
projected in columns


joins

protected java.util.List joins
inner/left/right joins


union

protected java.util.List union
union to many QueryExpressions


whereExpr

protected BooleanExpression whereExpr
filter condition


groupingExpressions

protected java.util.List groupingExpressions
User-provided expressions for GROUP BY clause.


havingExpr

protected BooleanExpression havingExpr
Expression for any HAVING clause.


orderingExpressions

protected ScalarExpression[] orderingExpressions
Expressions for any ORDER BY clause.


orderingDirections

protected boolean[] orderingDirections
Directions for any ORDER BY expressions (1 for each orderingExpressions entry).


stmtText

protected StatementText stmtText
Statement text for this Query Statement. Created once only.


stmtJoinsSeparator

protected char stmtJoinsSeparator
Separate joins e.g. FROM T1 JOIN T2 ON T1.ID=T2.ID JOIN T3 ON T3.ID=T2.ID, T4... This represents the space between "JOIN T2 ON T1.ID=T2.ID" AND "JOIN T3 ON T3.ID=T2.ID" in the above example


hasAggregateExpression

protected boolean hasAggregateExpression
whether there is an aggregate expression present in the select


joinsTo

protected java.util.List joinsTo
ensures that we don't have duplicate JOINs From vs To


crossJoins

protected java.util.List crossJoins
add tables/crossJoin but no joins to they, will be output as FROM TABLE1,TABLE2,TABLE3


isExistsSubQuery

protected boolean isExistsSubQuery
Whether this query is to be used as a as set for the Exists function.
e.g WHERE EXISTS(QUERY)
.


rangeOffset

protected long rangeOffset
The offset for any range restriction.


rangeCount

protected long rangeCount
The number of records to be retrieved in any range restriction.


useInnerJoinsOnly

protected boolean useInnerJoinsOnly
Flag to allow overriding of the default join type applied by JPOX.

Constructor Detail

QueryStatement

public QueryStatement(DatastoreContainerObject initialTable,
                      ClassLoaderResolver clr)
Constructor.

Parameters:
initialTable - The main table for this statement.
clr - ClassLoader resolver

QueryStatement

public QueryStatement(DatastoreContainerObject initialTable,
                      DatastoreIdentifier initialRangeVar,
                      ClassLoaderResolver clr)
Constructor. Used where the main table is not to be referred to as "THIS".

Parameters:
initialTable - The main table for this statement.
initialRangeVar - The alias for the main table
clr - ClassLoader resolver.
Method Detail

assertNotFrozen

protected void assertNotFrozen()

reset

public void reset()
Resets the compiled expression statement.

Specified by:
reset in interface QueryExpression

getClassLoaderResolver

public ClassLoaderResolver getClassLoaderResolver()
Accessor for the class-loader resolver.

Specified by:
getClassLoaderResolver in interface QueryExpression
Returns:
The ClassLoader resolver.

getInitialTableExpr

public LogicSetExpression getInitialTableExpr()
Accessor for the main table of this statement.

Returns:
Returns the main table expression

getStoreManager

public StoreManager getStoreManager()
Accessor for the Store Manager.

Specified by:
getStoreManager in interface QueryExpression
Returns:
The Store Manager.

getTableExpression

public LogicSetExpression getTableExpression(DatastoreIdentifier rangeVar)
Accessor for the table with the specified "alias". Returns null if the table is not utilised in this query expression.

Specified by:
getTableExpression in interface QueryExpression
Parameters:
rangeVar - Alias for the table required
Returns:
The table expression

getDefaultTableExpression

public LogicSetExpression getDefaultTableExpression()
Accessor for the main table for this query statement.

Specified by:
getDefaultTableExpression in interface QueryExpression
Returns:
The main table for this query

newTableExpression

public LogicSetExpression newTableExpression(DatastoreContainerObject mainTable,
                                             DatastoreIdentifier rangeVar)
Description copied from interface: QueryExpression
Creates a table expression

Specified by:
newTableExpression in interface QueryExpression
Parameters:
mainTable - the main table
rangeVar - the range var
Returns:
TableExpression

newTableExpression

public LogicSetExpression[] newTableExpression(DatastoreContainerObject mainTable,
                                               DatastoreIdentifier rangeVar,
                                               boolean unionQueries)
Description copied from interface: QueryExpression
Creates a table expression

Specified by:
newTableExpression in interface QueryExpression
Parameters:
mainTable - the main table
rangeVar - the range var
unionQueries - Whether to add to any union
Returns:
TableExpression[]

getDistinctResults

public boolean getDistinctResults()
Accessor for whether this query will return distinct results.

Returns:
Whether it returns distinct

setDistinctResults

public void setDistinctResults(boolean distinctResults)
Mutator for whether the query returns distinct results.

Specified by:
setDistinctResults in interface QueryExpression
Parameters:
distinctResults - Whether to return distinct

setExistsSubQuery

public void setExistsSubQuery(boolean isExistsSubQuery)
Set this query is to be used as a set for the Exists function. example WHERE EXISTS (QUERY)

Specified by:
setExistsSubQuery in interface QueryExpression
Parameters:
isExistsSubQuery - The isExistsSubQuery to set.

union

public void union(QueryExpression expr)
Method to union this query statement with another query statement.

Specified by:
union in interface QueryExpression
Parameters:
expr - The other query statement to union

getUseInnerJoinsOnly

public boolean getUseInnerJoinsOnly()
Accessor for whether to only use inner joins.

Returns:
Whether to only use inner joins.

setUseInnerJoinsOnly

public void setUseInnerJoinsOnly(boolean innerJoins)
Mutator for whether to use only inner joins.

Specified by:
setUseInnerJoinsOnly in interface QueryExpression
Parameters:
innerJoins - Whether to just use inner joins

selectDatastoreIdentity

public int[] selectDatastoreIdentity(java.lang.String alias,
                                     boolean unionQueries)
Select the datastore identity of the primary table of the query.

Specified by:
selectDatastoreIdentity in interface QueryExpression
Parameters:
alias - Alias to use for the selected datastore identity column (if any)
unionQueries - Whether to apply to the primary table of any unioned tables
Returns:
Index of the column in the select (or null if not datastore mapping)

selectVersion

public int[] selectVersion(java.lang.String alias,
                           boolean unionQueries)
Select the version column of the primary table of the query.

Specified by:
selectVersion in interface QueryExpression
Parameters:
alias - Alias to use for the selected version column (if any)
unionQueries - Whether to also select the version column of the primary table of any unioned queries
Returns:
Index of the column in the select (or null if no version mapping)

selectField

public int[] selectField(java.lang.String fieldName,
                         java.lang.String alias,
                         boolean unionQueries)
Select the column(s) for the specified field of the primary table of the query.

Specified by:
selectField in interface QueryExpression
Parameters:
fieldName - Name of the field to select.
alias - Alias to use for the selected field column(s) (if any).
unionQueries - Whether to also select the field column(s) of the primary table of any unioned queries
Returns:
Index of the column(s) in the select (or null of no field of this name present).

selectVersion

public int[] selectVersion(java.lang.String alias)
Select the version column of the primary table of the query.

Parameters:
alias - Alias to use for the selected version column (if any)
Returns:
Index of the column in the select (or null if no version mapping)

select

public int[] select(JavaTypeMapping mapping)
Select the columns for a mapping.

Specified by:
select in interface QueryExpression
Parameters:
mapping - The mapping
Returns:
The index of the columns in the select

select

public int[] select(JavaTypeMapping mapping,
                    boolean unionQueries)
select a new column, add to union queries, if unionQueries is true

Specified by:
select in interface QueryExpression
Parameters:
mapping - The mapping
unionQueries - Whether to add to any union
Returns:
The index of the columns in the select

select

public int[] select(DatastoreIdentifier rangeVar,
                    JavaTypeMapping mapping)
Select columns of the specified mapping for the table identifier.

Specified by:
select in interface QueryExpression
Parameters:
rangeVar - The range variable
mapping - The mapping
Returns:
The index of the columns in the select

select

public int[] select(DatastoreIdentifier rangeVar,
                    JavaTypeMapping mapping,
                    boolean unionQueries)
select columns, add to union queries, if unionQueries is true

Specified by:
select in interface QueryExpression
Parameters:
rangeVar - The range variable
mapping - The mapping
unionQueries - Whether to add to any union
Returns:
The index of the column in the select

selectScalarExpression

public int selectScalarExpression(ScalarExpression expr)
Select an expression.

Specified by:
selectScalarExpression in interface QueryExpression
Parameters:
expr - The expression to add to the select statement
Returns:
The index of the expression in the select

selectScalarExpression

public int selectScalarExpression(ScalarExpression expr,
                                  boolean unionQueries)
Select an expression.

Specified by:
selectScalarExpression in interface QueryExpression
Parameters:
expr - The expression to add to the select statement
unionQueries - whether to apply the select in all queries unified by the union clause
Returns:
The index of the expression in the select

getNumberOfScalarExpressions

public int getNumberOfScalarExpressions()
Accessor for the number of ScalarExpression projected.

Specified by:
getNumberOfScalarExpressions in interface QueryExpression
Returns:
The number of columns in the SELECT

hasMetaDataExpression

public boolean hasMetaDataExpression()
Whether this query will return a meta data expression (containing JPOXMETADATA).

Specified by:
hasMetaDataExpression in interface QueryExpression
Returns:
true if a meta data expression is returned by this query

hasCrossJoin

public boolean hasCrossJoin(LogicSetExpression tableExpr)
Method to add tables/alias but no joins to they, will be output as FROM TABLE1,TABLE2,TABLE3

Specified by:
hasCrossJoin in interface QueryExpression
Parameters:
tableExpr - table expression

crossJoin

public void crossJoin(LogicSetExpression tableExpr,
                      boolean unionQueries)
Method to add tables/alias but no joins to they, will be output as FROM TABLE1,TABLE2,TABLE3

Specified by:
crossJoin in interface QueryExpression
Parameters:
tableExpr - table expression
unionQueries - Whether to apply the alias to unions of this query.

join

public void join(ScalarExpression expr1,
                 ScalarExpression expr2,
                 LogicSetExpression tblExpr,
                 int joinType,
                 boolean equals,
                 boolean unionQueries)
Method to add a join to another table.

Parameters:
expr1 - the left hand expression
expr2 - the right hand expression
tblExpr - The table expression for the table to apply the join
joinType - Type of join
equals - if the join is applied as filter, if use equals or not equals
unionQueries - Whether to apply to all unioned queries as well

join

public void join(ScalarExpression expr1,
                 ScalarExpression expr2,
                 LogicSetExpression tblExpr,
                 int joinType,
                 boolean equals)
Method to do a join to another table.

Parameters:
expr1 - the left hand expression
expr2 - the right hand expression
tblExpr - The table expression for the table to apply the join
joinType - Type of join
equals - if the join is applied as filter, if use equals or not equals

innerJoin

public void innerJoin(ScalarExpression expr,
                      ScalarExpression expr2,
                      LogicSetExpression tblExpr,
                      boolean equals,
                      boolean unionQueries)
Method to do an inner join to another table, and optionally apply it to any unions for this query.

Specified by:
innerJoin in interface QueryExpression
Parameters:
expr - the left hand expression
expr2 - the right hand expression
tblExpr - the
equals - if the join is applied as filter, if use equals or not equals
unionQueries - whether to apply the inner join in all queries unified by the union clause

innerJoin

public void innerJoin(ScalarExpression expr,
                      ScalarExpression expr2,
                      LogicSetExpression tblExpr,
                      boolean equals)
Method to do an inner join to another table.

Specified by:
innerJoin in interface QueryExpression
Parameters:
expr - the left hand expression
expr2 - the right hand expression
tblExpr - The table expression for the table to apply the join
equals - if the join is applied as filter, if use equals or not equals

leftOuterJoin

public void leftOuterJoin(ScalarExpression expr,
                          ScalarExpression expr2,
                          LogicSetExpression tblExpr,
                          boolean equals,
                          boolean unionQueries)
Method to do a left outer join to another table, and optionally apply it to any unions for this query.

Specified by:
leftOuterJoin in interface QueryExpression
Parameters:
expr - the left hand expression
expr2 - the right hand expression
tblExpr - The table expression for the table to apply the join
equals - if the join is applied as filter, if use equals or not equals
unionQueries - Whether to apply to unions of this query.

leftOuterJoin

public void leftOuterJoin(ScalarExpression expr,
                          ScalarExpression expr2,
                          LogicSetExpression tblExpr,
                          boolean equals)
Method to do a left outer join to another table.

Specified by:
leftOuterJoin in interface QueryExpression
Parameters:
expr - the left hand expression
expr2 - the right hand expression
tblExpr - The table expression
equals - if the join is applied as filter, if use equals or not equals

rightOuterJoin

public void rightOuterJoin(ScalarExpression expr,
                           ScalarExpression expr2,
                           LogicSetExpression tblExpr,
                           boolean equals,
                           boolean unionQueries)
Method to do a right outer join to another table, and optionally apply it to any unions for this query.

Specified by:
rightOuterJoin in interface QueryExpression
Parameters:
expr - the left hand expression
expr2 - the right hand expression
tblExpr - The table expression for the table to apply the join
equals - if the join is applied as filter, if use equals or not equals
unionQueries - Whether to apply to unions of this query.

rightOuterJoin

public void rightOuterJoin(ScalarExpression expr,
                           ScalarExpression expr2,
                           LogicSetExpression tblExpr,
                           boolean equals)
Method to do a right outer join to another table.

Specified by:
rightOuterJoin in interface QueryExpression
Parameters:
expr - the left hand expression
expr2 - the right hand expression
tblExpr - The table expression for the table to apply the join
equals - if the join is applied as filter, if use equals or not equals

andCondition

public void andCondition(BooleanExpression condition,
                         boolean unionQueries)
add an condition to the query and queries involved in the union if unionQuery is true

Specified by:
andCondition in interface QueryExpression
Parameters:
condition - the Boolean expression
unionQueries - whether to apply the condition in all queries unified by the union clause

andCondition

public void andCondition(BooleanExpression condition)
Method to add an additional WHERE clause to the query.

Specified by:
andCondition in interface QueryExpression
Parameters:
condition - The where clause expression

iorCondition

public void iorCondition(BooleanExpression condition,
                         boolean unionQueries)
add an condition to the query and queries involved in the union if unionQuery is true

Specified by:
iorCondition in interface QueryExpression
Parameters:
condition - the Boolean expression
unionQueries - whether to apply the condition in all queries unified by the union clause

iorCondition

public void iorCondition(BooleanExpression condition)
Method to add an IOR condition to the WHERE clause of the statement.

Specified by:
iorCondition in interface QueryExpression
Parameters:
condition - The WHERE clause expression

addGroupingExpression

public void addGroupingExpression(ScalarExpression expr)
Method to add a grouping expression to the query.

Specified by:
addGroupingExpression in interface QueryExpression
Parameters:
expr - The expression

getGroupingExpressions

public ScalarExpression[] getGroupingExpressions()
Accessor for the grouping expressions (if any).

Specified by:
getGroupingExpressions in interface QueryExpression
Returns:
The grouping expressions

setHaving

public void setHaving(BooleanExpression expr)
Mutator for the "having" expression.

Specified by:
setHaving in interface QueryExpression
Parameters:
expr - Boolean expression for the having clause

getHavingExpression

public BooleanExpression getHavingExpression()
Accessor for the having expression (if any).

Specified by:
getHavingExpression in interface QueryExpression
Returns:
The having expression

setOrdering

public void setOrdering(ScalarExpression[] exprs,
                        boolean[] descending)
Mutator for the ordering criteria.

Specified by:
setOrdering in interface QueryExpression
Parameters:
exprs - The expressions to order by
descending - Whether each expression is ascending/descending

getOrderingExpressions

public ScalarExpression[] getOrderingExpressions()
Accessor for the ordering expressions (if any).

Specified by:
getOrderingExpressions in interface QueryExpression
Returns:
The ordering expressions

setRangeConstraint

public void setRangeConstraint(long offset,
                               long count)
Method to add a range constraint on any SELECT. This typically will use LIMIT/OFFSET where they are supported by the underlying RDBMS.

Specified by:
setRangeConstraint in interface QueryExpression
Parameters:
offset - The offset to start from
count - The number of records to return

toDeleteStatementText

public StatementText toDeleteStatementText()
Method to convert the criteria into a delete statement text.

Specified by:
toDeleteStatementText in interface QueryExpression
Returns:
The StatementText

addOrderingColumnsToSelect

protected void addOrderingColumnsToSelect()
Convenience method to add any necessary columns to the SELECT that are needed by the ordering constraint.


generateOrderingStatement

protected StatementText generateOrderingStatement()
Convenience method to generate the ordering statement to add to the overall query statement.

Returns:
The ordering statement

toStatementText

public StatementText toStatementText(boolean lock)
Method to convert the criteria into the statement text.

Specified by:
toStatementText in interface QueryExpression
Parameters:
lock - whether to lock the instances using this statement
Returns:
The StatementText

toString

public java.lang.String toString()

toString

public java.lang.String toString(boolean lock)
Stringifier

Parameters:
lock - Whether to lock the rows found by this SELECT
Returns:
The string form of the statement


Copyright © -2007 . All Rights Reserved.