org.datanucleus.store.mapped.expression
Class ObjectExpression

java.lang.Object
  extended by org.datanucleus.store.mapped.expression.ScalarExpression
      extended by org.datanucleus.store.mapped.expression.ObjectExpression
Direct Known Subclasses:
ObjectLiteral

public class ObjectExpression
extends ScalarExpression

Representation of an Object expression in a Query. 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.someField == value" then
 "b" is interpreted first and an ObjectExpression is created to represent
 that object (of type B).
 
The expression has an associated TableExpression, and a list of expressions which represent the datastore columns identifying the object (the PK fields/columns).

Version:
$Revision: 1.59 $

Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.mapped.expression.ScalarExpression
ScalarExpression.DatastoreFieldExpression, ScalarExpression.DyadicOperator, ScalarExpression.ExpressionList, ScalarExpression.IllegalArgumentTypeException, ScalarExpression.IllegalOperationException, ScalarExpression.MethodInvocationException, ScalarExpression.MonadicOperator, ScalarExpression.Operator
 
Field Summary
protected  ScalarExpression conditionExpr
           
 
Fields inherited from class org.datanucleus.store.mapped.expression.ScalarExpression
aliasIdentifier, checkForTypeAssignability, expressionList, FILTER, LOCALISER, lowestOperator, mapping, OP_ADD, OP_AND, OP_BETWEEN, OP_COM, OP_CONCAT, OP_DIV, OP_EQ, OP_GT, OP_GTEQ, OP_IN, OP_IS, OP_ISNOT, OP_LIKE, OP_LT, OP_LTEQ, OP_MOD, OP_MUL, OP_NEG, OP_NOT, OP_NOTEQ, OP_NOTIN, OP_NOTLIKE, OP_OR, OP_SUB, parameterName, PROJECTION, qs, st, te
 
Constructor Summary
protected ObjectExpression(QueryExpression qs)
           
  ObjectExpression(QueryExpression qs, JavaTypeMapping mapping, LogicSetExpression te)
          Constructor for an object expression, using the mapping of the field, and the expression for the table.
  ObjectExpression(QueryExpression qs, JavaTypeMapping mapping, LogicSetExpression te, JavaTypeMapping refMapping, LogicSetExpression teTarget, JavaTypeMapping selectMapping)
          Constructor for an object expression, using the mapping of the field (which has no datastore columns), the expression for its table, the mapping for a field in another table to join to, and the expression for the other table.
  ObjectExpression(QueryExpression qs, ScalarExpression expr, ScalarExpression conditionExpr, LogicSetExpression te)
          Construct an object expression conditioned to a boolean expression If this expression is an operand of an operation with result type Boolean has the following semantic if (conditionExpr == null ) return (otherExpression op expr); else return (otherExpression op expr) & conditionExpr;
 
Method Summary
 ScalarExpression accessField(java.lang.String subfieldName, boolean innerJoin)
          Access a field in the object that this expression represents.
 void addOuterJoinSuffix(java.lang.String suffix)
          Convenience method to add an outer join suffix.
 ScalarExpression cast(java.lang.Class castType)
          Cast operator.
 BooleanExpression eq(ScalarExpression expr)
          Equals operator.
 BooleanExpression in(ScalarExpression expr)
          In expression.
 BooleanExpression instanceOf(ScalarExpression expr)
          Method to return a constraint for restricting the field to just instances of a particular class.
 BooleanExpression noteq(ScalarExpression expr)
          Not equals operator.
 void setFieldDefinition(java.lang.String fieldName, java.lang.String fieldType)
          Set the field which this expression was created from.
 void useIdentityFormOfPCMapping()
          Convenience method for the case where the mapping being used is a PersistenceCapableMapping and where we want to represent the identity instead of the object represented by that mapping.
 
Methods inherited from class org.datanucleus.store.mapped.expression.ScalarExpression
add, and, as, assertValidTypeForParameterComparison, callMethod, checkForTypeAssignability, com, div, encloseWithInParentheses, eor, equals, getAlias, getConsistentTypeForParameterComparison, getExpressionList, getLogicSetExpression, getMapping, getNonAliasExpression, getParameterName, getQueryExpression, gt, gteq, ior, isParameter, lt, lteq, mod, mul, neg, not, setParameterName, sub, toStatementText, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

conditionExpr

protected ScalarExpression conditionExpr
Constructor Detail

ObjectExpression

protected ObjectExpression(QueryExpression qs)

ObjectExpression

public ObjectExpression(QueryExpression qs,
                        JavaTypeMapping mapping,
                        LogicSetExpression te)
Constructor for an object expression, using the mapping of the field, and the expression for the table.

Parameters:
qs - The Query Statement
mapping - The mapping for the field whose object we are expressing
te - The expression for the table of the object.

ObjectExpression

public ObjectExpression(QueryExpression qs,
                        JavaTypeMapping mapping,
                        LogicSetExpression te,
                        JavaTypeMapping refMapping,
                        LogicSetExpression teTarget,
                        JavaTypeMapping selectMapping)
Constructor for an object expression, using the mapping of the field (which has no datastore columns), the expression for its table, the mapping for a field in another table to join to, and the expression for the other table. This is for use in 2 situations :-

Parameters:
qs - The Query Statement
mapping - The mapping for the field whose object we are expressing
te - The expression for the table of the object
refMapping - The mapping of the field in another table that we join to
teTarget - The expression for the other table that we are joining to.
selectMapping - The mapping that we should select in the other table

ObjectExpression

public ObjectExpression(QueryExpression qs,
                        ScalarExpression expr,
                        ScalarExpression conditionExpr,
                        LogicSetExpression te)
Construct an object expression conditioned to a boolean expression If this expression is an operand of an operation with result type Boolean has the following semantic if (conditionExpr == null ) return (otherExpression op expr); else return (otherExpression op expr) & conditionExpr;

Parameters:
qs - the QueryExpression
expr - the expression
conditionExpr - the conditional boolean expression
te - the TableExpression
Method Detail

useIdentityFormOfPCMapping

public void useIdentityFormOfPCMapping()
Convenience method for the case where the mapping being used is a PersistenceCapableMapping and where we want to represent the identity instead of the object represented by that mapping. This changes the mapping to use the id.


addOuterJoinSuffix

public void addOuterJoinSuffix(java.lang.String suffix)
Convenience method to add an outer join suffix. Particularly for use with Oracle (8) which uses syntax like table1.col1 = table2.col2 (+),

Parameters:
suffix - The suffix

cast

public ScalarExpression cast(java.lang.Class castType)
Cast operator. Called when the query contains "(type)obj" where "obj" is this object.

Overrides:
cast in class ScalarExpression
Parameters:
castType - The type we cast this object to
Returns:
Scalar expression representing the cast object.

eq

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

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

noteq

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

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

in

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

Overrides:
in in class ScalarExpression
Parameters:
expr - the right-hand expression
Returns:
true if the left-hand expression is contained by the right-hand expression. Otherwise the result is false.

accessField

public ScalarExpression accessField(java.lang.String subfieldName,
                                    boolean innerJoin)
Access a field in the object that this expression represents. If the field is contained in a different table then will use the "innerJoin" input parameter and make a join to the required table. If the field is a 1-1 relation and the current table holds the FK then no join will be made.

Overrides:
accessField in class ScalarExpression
Parameters:
subfieldName - the field to be accessed in this object
innerJoin - whether to inner join
Returns:
The field expression representing the required field of this object

instanceOf

public BooleanExpression instanceOf(ScalarExpression expr)
Method to return a constraint for restricting the field to just instances of a particular class.

Overrides:
instanceOf in class ScalarExpression
Parameters:
expr - Expression for the class that we want instances of (a ClassExpression).
Returns:
The expression for the instanceof clause

setFieldDefinition

public void setFieldDefinition(java.lang.String fieldName,
                               java.lang.String fieldType)
Set the field which this expression was created from.

Parameters:
fieldName - The fieldName to set.
fieldType - The fieldType to set


Copyright © 2009. All Rights Reserved.