Class ObjectExpression
java.lang.Object
org.datanucleus.store.rdbms.sql.expression.SQLExpression
org.datanucleus.store.rdbms.sql.expression.ObjectExpression
- Direct Known Subclasses:
ObjectLiteral
,TypeConverterMultiExpression
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
ConstructorsConstructorDescriptionObjectExpression
(SQLStatement stmt, JavaTypeMapping mapping, String functionName, List<SQLExpression> args) Generates statement as "FUNCTION_NAME(arg [,argN])".ObjectExpression
(SQLStatement stmt, JavaTypeMapping mapping, String functionName, List<SQLExpression> args, List<Object> 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
Modifier and TypeMethodDescriptionprotected void
Updates the supplied expression with sub-expressions of consistent types to this expression.cast
(SQLExpression expr) Cast operator.eq
(SQLExpression expr) Equals operator.ge
(SQLExpression expr) Relational operator (greater than or equals)gt
(SQLExpression expr) Relational operator (greater than)in
(SQLExpression expr, boolean not) In expression.invoke
(String methodName, List<SQLExpression> args) Invocation of a method on this expression.is
(SQLExpression expr, boolean not) An "is" (instanceOf) expression, providing a BooleanExpression whether this expression is an instanceof the provided type.le
(SQLExpression expr) Relational operator (lower than or equals)private boolean
Convenience method to return if this object is valid for simple comparison with the passed expression.lt
(SQLExpression expr) Relational operator (lower than)ne
(SQLExpression expr) Not equals operator.protected BooleanExpression
processComparisonOfImplementationWithReference
(SQLExpression refExpr, SQLExpression implExpr, boolean negate) void
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 Details
-
ObjectExpression
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<SQLExpression> 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<SQLExpression> args, List<Object> 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 Details
-
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
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
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
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
-
literalIsValidForSimpleComparison
Convenience method to return if this object is valid for simple comparison with the passed expression. Performs a type comparison of the object and the expression for compatibility. The expression must be a literal of a suitable type for simple comparison (e.g where this object is a String, and the literal is a StringLiteral).- Parameters:
expr
- The expression- Returns:
- Whether a simple comparison is valid
-
in
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
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
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
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
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
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
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
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
-