Class ObjectExpression
- java.lang.Object
-
- org.datanucleus.store.rdbms.sql.expression.SQLExpression
-
- org.datanucleus.store.rdbms.sql.expression.ObjectExpression
-
- Direct Known Subclasses:
ObjectLiteral
,TypeConverterMultiExpression
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
-
Fields inherited from class org.datanucleus.store.rdbms.sql.expression.SQLExpression
lowestOperator, mapping, parameterName, st, stmt, subExprs, table
-
-
Constructor Summary
Constructors Constructor Description ObjectExpression(SQLStatement stmt, JavaTypeMapping mapping, String functionName, List args)
Generates statement as "FUNCTION_NAME(arg [,argN])".ObjectExpression(SQLStatement stmt, JavaTypeMapping mapping, String functionName, List args, List types)
Generates statement as "FUNCTION_NAME(arg [AS type] [,argN [AS typeN]])".ObjectExpression(SQLStatement stmt, SQLTable table, JavaTypeMapping mapping)
Constructor for an SQL expression for a (field) mapping in a specified table.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
ge(SQLExpression expr)
Relational operator (greater than or equals)BooleanExpression
gt(SQLExpression expr)
Relational operator (greater than)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
le(SQLExpression expr)
Relational operator (lower than or equals)BooleanExpression
lt(SQLExpression expr)
Relational operator (lower than)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, bitAnd, bitOr, com, distinct, div, encloseInParentheses, eor, getJavaTypeMapping, getLowestOperator, getNumberOfSubExpressions, getParameterName, getSQLStatement, getSQLTable, getSubExpression, ior, isParameter, mod, mul, neg, not, setJavaTypeMapping, sub, toSQLText, unDistinct
-
-
-
-
Constructor Detail
-
ObjectExpression
public ObjectExpression(SQLStatement stmt, SQLTable table, JavaTypeMapping mapping)
Constructor for an SQL expression for a (field) mapping in a specified table.- Parameters:
stmt
- The statementtable
- The table in the statementmapping
- The mapping for the field
-
ObjectExpression
public ObjectExpression(SQLStatement stmt, JavaTypeMapping mapping, String functionName, List args)
Generates statement as "FUNCTION_NAME(arg [,argN])".- Parameters:
stmt
- The statementmapping
- Mapping to usefunctionName
- Name of functionargs
- SQLExpression list
-
ObjectExpression
public ObjectExpression(SQLStatement stmt, JavaTypeMapping mapping, String functionName, List args, List types)
Generates statement as "FUNCTION_NAME(arg [AS type] [,argN [AS typeN]])".- Parameters:
stmt
- The statementmapping
- Mapping to usefunctionName
- Name of functionargs
- SQLExpression listtypes
- Optional String/SQLExpression list of types for the args
-
-
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 classSQLExpression
- 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 classSQLExpression
- 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 byexpr
- Overrides:
in
in classSQLExpression
- Parameters:
expr
- the right-hand expressionnot
- 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.
-
lt
public BooleanExpression lt(SQLExpression expr)
Description copied from class:SQLExpression
Relational operator (lower than)- Overrides:
lt
in classSQLExpression
- Parameters:
expr
- the right-hand operand- Returns:
- true if the value of the left-hand operand is less than the value of the right-hand operand, and otherwise is false.
-
le
public BooleanExpression le(SQLExpression expr)
Description copied from class:SQLExpression
Relational operator (lower than or equals)- Overrides:
le
in classSQLExpression
- Parameters:
expr
- the right-hand operand- Returns:
- true if the value of the left-hand operand is less than or equal to the value of the right-hand operand, and otherwise is false.
-
gt
public BooleanExpression gt(SQLExpression expr)
Description copied from class:SQLExpression
Relational operator (greater than)- Overrides:
gt
in classSQLExpression
- Parameters:
expr
- the right-hand operand- Returns:
- true if the value of the left-hand operand is greater than the value of the right-hand operand, and otherwise is false.
-
ge
public BooleanExpression ge(SQLExpression expr)
Description copied from class:SQLExpression
Relational operator (greater than or equals)- Overrides:
ge
in classSQLExpression
- Parameters:
expr
- the right-hand operand- Returns:
- true if the value of the left-hand operand is greater than or equal the value of the right-hand operand, and otherwise 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 classSQLExpression
- 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 classSQLExpression
- Parameters:
expr
- The expression representing the typenot
- 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 classSQLExpression
- Parameters:
methodName
- name of the method to invokeargs
- Args to this method (if any)- Returns:
- the converted value
-
-