com.triactive.jdo.store.sql.expr
Class QueryStatement.QueryColumn

java.lang.Object
  extended bycom.triactive.jdo.store.sql.expr.QueryStatement.QueryColumn
Enclosing class:
QueryStatement

public static class QueryStatement.QueryColumn
extends java.lang.Object

Represents a column in one of the table expressions in a query statement. A query column object is essentially the pair [TableExpression,Column], and equates to a SQL fragment such as "T1.COL".

A query column can be created and manipulated without necessarily being "used" in the actual query statement. If it is to be used, meaning some SqlExpression fragment wants to include a reference to the column, then the reference() method must be called to indicate the column is actually being referenced.

Furthermore, a call to reference() cannot be postponed until the time that statement text is being generated (i.e. StatementTextGenerator.toStatementText()). It must be knowable in advance (by, for instance, a call to SqlExpression.getReferencedColumns()) which columns are being referenced. Mainly this is because referencing a column may cause its table expression to mutate. To help enforce this in the code an unreferenced query column throws an exception if its toString() method is called.


Field Summary
 Column col
          The column within the table expression.
 TableExpression te
          The table expression of this query column.
 
Method Summary
 boolean equals(java.lang.Object o)
          Tests this object for equality with another object.
 QueryStatement getQueryStatement()
          Returns the query statement to which this query column belongs.
 CorrelationName getRangeVariable()
          Returns the range variable (table alias) for the column in its query statement.
 int hashCode()
          Returns a hash code value for this object.
 boolean isOuterJoined()
          Returns true if the query column belongs to a table expression that was outer-joined at any point.
 void reference()
          Generates a reference to the query column.
 SqlExpression toExpression()
          Returns a properly-typed SQL expression representing this query column.
 java.lang.String toString()
          Returns the string representation of this query column.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

te

public final TableExpression te
The table expression of this query column.


col

public final Column col
The column within the table expression.

Method Detail

getQueryStatement

public QueryStatement getQueryStatement()
Returns the query statement to which this query column belongs.


toExpression

public SqlExpression toExpression()
Returns a properly-typed SQL expression representing this query column.


reference

public void reference()
Generates a reference to the query column. Used to indicate that the column will actually be referenced by a SqlExpression. Referencing a query column may cause the composition of its table expression to be modified.


getRangeVariable

public CorrelationName getRangeVariable()
Returns the range variable (table alias) for the column in its query statement. If the column has not been referenced an exception is thrown.

Returns:
The range variable for the query column, such as "T1".
Throws:
java.lang.IllegalStateException - If the query column has not been referenced.

isOuterJoined

public boolean isOuterJoined()
Returns true if the query column belongs to a table expression that was outer-joined at any point.

Returns:
true if the column's table participated in an outer join at any point.

hashCode

public int hashCode()
Returns a hash code value for this object.


equals

public boolean equals(java.lang.Object o)
Tests this object for equality with another object. Two QueryColumn objects are equal if they refer to the same TableExpression and Column.


toString

public java.lang.String toString()
Returns the string representation of this query column. If the column has been referenced the SQL reference string is returned, otherwise an exception is thrown.

Returns:
An SQL reference to the query column, such as "T1.COL".
Throws:
java.lang.IllegalStateException - If the query column has not been referenced.


Copyright © 2001-2007 The TJDO Project All Rights Reserved.