org.datanucleus.store.rdbms.sql.expression
Class ObjectExpression

java.lang.Object
  extended by org.datanucleus.store.rdbms.sql.expression.SQLExpression
      extended by org.datanucleus.store.rdbms.sql.expression.ObjectExpression
Direct Known Subclasses:
ObjectLiteral

public class ObjectExpression
extends SQLExpression

Representation of an Object expression in a Query. Typically represents a persistable object, and so its identity, though could be used to represent any Object.

Let's take an example. We have classes A and B, and A contains a reference to B "b". If we do a JDOQL query for class A of "b == value" then "b" is interpreted first and an ObjectExpression is created to represent that object (of type B).


Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.rdbms.sql.expression.SQLExpression
SQLExpression.ColumnExpressionList
 
Field Summary
protected static org.datanucleus.util.Localiser LOCALISER_CORE
          Localiser for messages
 
Fields inherited from class org.datanucleus.store.rdbms.sql.expression.SQLExpression
LOCALISER, lowestOperator, mapping, parameterName, st, stmt, subExprs, table
 
Constructor Summary
ObjectExpression(SQLStatement stmt, SQLTable table, org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping)
          Constructor for an SQL expression for a (field) mapping in a specified table.
 
Method Summary
protected  void addSubexpressionsToRelatedExpression(SQLExpression expr)
          Updates the supplied expression with sub-expressions of consistent types to this expression.
 SQLExpression cast(SQLExpression expr)
          Cast operator.
 BooleanExpression eq(SQLExpression expr)
          Equals operator.
 BooleanExpression in(SQLExpression expr, boolean not)
          In expression.
 SQLExpression invoke(String methodName, List args)
          Invocation of a method on this expression.
 BooleanExpression is(SQLExpression expr, boolean not)
          An "is" (instanceOf) expression, providing a BooleanExpression whether this expression is an instanceof the provided type.
 BooleanExpression ne(SQLExpression expr)
          Not equals operator.
protected  BooleanExpression processComparisonOfImplementationWithReference(SQLExpression refExpr, SQLExpression implExpr, boolean negate)
           
 void useFirstColumnOnly()
          Method to change the expression to use only the first column.
 
Methods inherited from class org.datanucleus.store.rdbms.sql.expression.SQLExpression
add, and, com, distinct, div, encloseInParentheses, eor, ge, getJavaTypeMapping, getLowestOperator, getNumberOfSubExpressions, getParameterName, getSQLStatement, getSQLTable, getSubExpression, gt, ior, isParameter, le, lt, mod, mul, neg, not, setJavaTypeMapping, sub, toSQLText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER_CORE

protected static final org.datanucleus.util.Localiser LOCALISER_CORE
Localiser for messages

Constructor Detail

ObjectExpression

public ObjectExpression(SQLStatement stmt,
                        SQLTable table,
                        org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping)
Constructor for an SQL expression for a (field) mapping in a specified table.

Parameters:
stmt - The statement
table - The table in the statement
mapping - The mapping for the field
Method Detail

useFirstColumnOnly

public void useFirstColumnOnly()
Method to change the expression to use only the first column. This is used where we want to use the expression with COUNT(...) and that only allows 1 column.


eq

public BooleanExpression eq(SQLExpression expr)
Equals operator. Called when the query contains "obj == value" where "obj" is this object.

Overrides:
eq in class SQLExpression
Parameters:
expr - The expression we compare with (the right-hand-side in the query)
Returns:
Boolean expression representing the comparison.

processComparisonOfImplementationWithReference

protected BooleanExpression processComparisonOfImplementationWithReference(SQLExpression refExpr,
                                                                           SQLExpression implExpr,
                                                                           boolean negate)

ne

public BooleanExpression ne(SQLExpression expr)
Not equals operator. Called when the query contains "obj != value" where "obj" is this object.

Overrides:
ne in class SQLExpression
Parameters:
expr - The expression we compare with (the right-hand-side in the query)
Returns:
Boolean expression representing the comparison.

addSubexpressionsToRelatedExpression

protected void addSubexpressionsToRelatedExpression(SQLExpression expr)
Updates the supplied expression with sub-expressions of consistent types to this expression. This is called when we have some comparison expression (e.g this == expr) and where the other expression has no sub-expressions currently.

Parameters:
expr - The expression

in

public BooleanExpression in(SQLExpression expr,
                            boolean not)
Description copied from class: SQLExpression
In expression. Return true if this is contained by expr

Overrides:
in in class SQLExpression
Parameters:
expr - the right-hand expression
not - Whether we really want "not in"
Returns:
true if the left-hand expression is contained by the right-hand expression. Otherwise the result is false.

cast

public SQLExpression cast(SQLExpression expr)
Cast operator. Called when the query contains "(type)obj" where "obj" is this object.

Overrides:
cast in class SQLExpression
Parameters:
expr - Expression representing the type to cast to
Returns:
Scalar expression representing the cast object.

is

public BooleanExpression is(SQLExpression expr,
                            boolean not)
An "is" (instanceOf) expression, providing a BooleanExpression whether this expression is an instanceof the provided type.

Overrides:
is in class SQLExpression
Parameters:
expr - The expression representing the type
not - Whether the operator is "!instanceof"
Returns:
Whether this expression is an instance of the provided type

invoke

public SQLExpression invoke(String methodName,
                            List args)
Description copied from class: SQLExpression
Invocation of a method on this expression.

Overrides:
invoke in class SQLExpression
Parameters:
methodName - name of the method to invoke
args - Args to this method (if any)
Returns:
the converted value


Copyright © 2012. All Rights Reserved.