Class ComparisonExpressionStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.ComparisonExpressionStateObject
- All Implemented Interfaces:
StateObject
Only the values of like types are permitted to be compared. A type is like another type if they
correspond to the same Java language type, or if one is a primitive Java language type and the
other is the wrapped Java class type equivalent (e.g., int and Integer are like types in this
sense).
There is one exception to this rule: it is valid to compare numeric values for which the rules of numeric promotion apply. Conditional expressions attempting to compare non-like type values are disallowed except for this numeric case.
Note that the arithmetic operators and comparison operators are permitted to be applied to state-fields and input parameters of the wrapped Java class equivalents to the primitive numeric Java types. Two entities of the same abstract schema type are equal if and only if they have the same primary key value. Only equality/inequality comparisons over enumeration constants are required to be supported.
JPA 1.0 - BNF:
comparison_expression ::= string_expression comparison_operator {string_expression | all_or_any_expression} |
boolean_expression {=|<>} {boolean_expression | all_or_any_expression} |
enum_expression {=|<>} {enum_expression | all_or_any_expression} |
datetime_expression comparison_operator {datetime_expression | all_or_any_expression} |
entity_expression {=|<>} {entity_expression | all_or_any_expression} |
arithmetic_expression comparison_operator {arithmetic_expression | all_or_any_expression}
JPA 2.0 - BNF:
comparison_expression ::= string_expression comparison_operator {string_expression | all_or_any_expression} |
boolean_expression {=|<>} {boolean_expression | all_or_any_expression} |
enum_expression {=|<>} {enum_expression | all_or_any_expression} |
datetime_expression comparison_operator {datetime_expression | all_or_any_expression} |
entity_expression {=|<>} {entity_expression | all_or_any_expression} |
arithmetic_expression comparison_operator {arithmetic_expression | all_or_any_expression} |
entity_type_expression {=|<>} entity_type_expression}
- Since:
- 2.4
- Version:
- 2.4
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Notifies the identifier property has changed.Fields inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject
LEFT_STATE_OBJECT_PROPERTY, RIGHT_STATE_OBJECT_PROPERTY
-
Constructor Summary
ConstructorDescriptionComparisonExpressionStateObject
(StateObject parent, String identifier) Creates a newComparisonExpressionStateObject
.ComparisonExpressionStateObject
(StateObject parent, String leftJpqlFragment, String identifier, String rightJpqlFragment) Creates a newComparisonExpressionStateObject
.ComparisonExpressionStateObject
(StateObject parent, StateObject leftStateObject, String identifier, StateObject rightStateObject) Creates a newComparisonExpressionStateObject
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(StateObjectVisitor visitor) Visits thisStateObject
by the givenvisitor
.Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.Returns the identifier joining the twoStateObjects
.protected String
Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the left side of the expression.protected String
Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the right side of the expression.boolean
isEquivalent
(StateObject stateObject) Determines whether the givenStateObject
is equivalent to this one, i.e.void
setExpression
(ComparisonExpression expression) Keeps a reference of theparsed object
object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects
.void
setIdentifier
(String identifier) Sets the comparison identifier to one of the following: <, <=, =, >=, <>.protected void
validateIdentifier
(String identifier) Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject
addChildren, getLeft, getRight, hasLeft, hasRight, parseLeft, parseRight, setLeft, setRight, toTextInternal
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, initialize, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
-
Field Details
-
IDENTIFIER_PROPERTY
Notifies the identifier property has changed.- See Also:
-
-
Constructor Details
-
ComparisonExpressionStateObject
public ComparisonExpressionStateObject(StateObject parent, StateObject leftStateObject, String identifier, StateObject rightStateObject) Creates a newComparisonExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
leftStateObject
- TheStateObject
representing the left expressionidentifier
- The comparison identifier, either <, <=, =, >=, <>rightStateObject
- TheStateObject
representing the right expression- Throws:
NullPointerException
- The given parent cannot benull
-
ComparisonExpressionStateObject
Creates a newComparisonExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
identifier
- The comparison identifier, either <, <=, =, >=, <>- Throws:
NullPointerException
- The given parent cannot benull
-
ComparisonExpressionStateObject
public ComparisonExpressionStateObject(StateObject parent, String leftJpqlFragment, String identifier, String rightJpqlFragment) Creates a newComparisonExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
leftJpqlFragment
- The string representation of the left expression to parse and to convert into aStateObject
identifier
- The comparison identifier, either <, <=, =, >=, <>rightJpqlFragment
- The string representation of the right expression to parse and to convert into aStateObject
- Throws:
NullPointerException
- The given parent cannot benull
-
-
Method Details
-
accept
Description copied from interface:StateObject
Visits thisStateObject
by the givenvisitor
.- Parameters:
visitor
- Thevisitor
to visit this object
-
getExpression
Description copied from interface:StateObject
Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpression
in interfaceStateObject
- Overrides:
getExpression
in classCompoundExpressionStateObject
- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObject
ornull
when the JPQL query is manually created (i.e. not from a string)
-
getIdentifier
Description copied from class:CompoundExpressionStateObject
Returns the identifier joining the twoStateObjects
.- Specified by:
getIdentifier
in classCompoundExpressionStateObject
- Returns:
- The JPQL identifier join two expressions
-
getLeftQueryBNFId
Description copied from class:CompoundExpressionStateObject
Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the left side of the expression.- Specified by:
getLeftQueryBNFId
in classCompoundExpressionStateObject
- Returns:
- The query BNF ID for the left side of the expression
-
getRightQueryBNFId
Description copied from class:CompoundExpressionStateObject
Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the right side of the expression.- Specified by:
getRightQueryBNFId
in classCompoundExpressionStateObject
- Returns:
- The query BNF ID for the right side of the expression
-
isEquivalent
Description copied from interface:StateObject
Determines whether the givenStateObject
is equivalent to this one, i.e. the information of bothStateObject
is the same.- Specified by:
isEquivalent
in interfaceStateObject
- Overrides:
isEquivalent
in classCompoundExpressionStateObject
- Parameters:
stateObject
- TheStateObject
to compare its content to this one- Returns:
true
if both object are equivalent;false
otherwise
-
setExpression
Keeps a reference of theparsed object
object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects
.- Parameters:
expression
- Theparsed object
representing a comparison expression
-
setIdentifier
Sets the comparison identifier to one of the following: <, <=, =, >=, <>.- Parameters:
identifier
- The new comparison identifier, either <, <=, =, >=, <>
-
validateIdentifier
-