Class CollectionMemberDeclarationStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.CollectionMemberDeclarationStateObject
- All Implemented Interfaces:
StateObject
,VariableDeclarationStateObject
public class CollectionMemberDeclarationStateObject
extends AbstractStateObject
implements VariableDeclarationStateObject
An identification variable declared by a
or
collection_member_declaration
ranges over
values of a collection obtained by navigation using a path expression. Such a path expression
represents a navigation involving the association-fields of an entity abstract schema type.
Because a path expression can be based on another path expression, the navigation can use the
association-fields of related entities. An identification variable of a collection member
declaration is declared using a special operator, the reserved identifier IN
.
The argument to the IN
operator is a collection-valued path expression. The
path expression evaluates to a collection type specified as a result of navigation to a
collection-valued association-field of an entity abstract schema type. The syntax for declaring a
collection member identification variable is as follows:
BNF: collection_member_declaration ::= IN(collection_valued_path_expression) [AS] identification_variable
BNF: derived_collection_member_declaration ::= IN superquery_identification_variable.{single_valued_object_field.}*collection_valued_field
- Since:
- 2.4
- Version:
- 2.5
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Notifies the visibility of theAS
identifier has changed. -
Constructor Summary
ConstructorDescriptionCreates a newCollectionMemberDeclarationStateObject
.CollectionMemberDeclarationStateObject
(AbstractFromClauseStateObject parent, ListIterator<String> paths, boolean as, String identificationVariable) Creates a newCollectionMemberDeclarationStateObject
.CollectionMemberDeclarationStateObject
(AbstractFromClauseStateObject parent, ListIterator<String> paths, String identificationVariable) Creates a newCollectionMemberDeclarationStateObject
.CollectionMemberDeclarationStateObject
(SimpleFromClauseStateObject parent, String collectionValuedPath) Creates a newCollectionMemberDeclarationStateObject
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(StateObjectVisitor visitor) Visits thisStateObject
by the givenvisitor
.addAs()
Makes sure theAS
identifier is specified.protected void
addChildren
(List<StateObject> children) Adds the children of thisStateObject
to the given list.Returns the model object representing the collection-valued association-field of an entity abstract schema type.Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.Returns the model object representing an identification variable evaluating to a collection-valued association-field of an entity abstract schema type.getManagedType
(StateObject stateObject) Returns theIManagedType
for the given identification variable.Returns the parent of thisStateObject
.boolean
hasAs()
Determines whether theAS
identifier is used or not.boolean
Determines whether an identification variable was defined.Returns theIdentificationVariableStateObject
that are used by this state object.protected void
Initializes this state object.boolean
Determines whether this collection member declaration is used as a derived collection-valued path expression.boolean
isEquivalent
(StateObject stateObject) Determines whether the givenStateObject
is equivalent to this one, i.e.void
removeAs()
Makes sure theAS
identifier is not specified.void
setAs
(boolean as) Sets whether theAS
identifier is used or not.void
setDerived
(boolean derived) Sets whether this collection member declaration is used as a derived collection-valued path expression.void
setExpression
(CollectionMemberDeclaration 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
setIdentificationVariable
(String identificationVariable) Sets the new identification variable that will range over the collection-valued path.void
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.void
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.void
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.void
setPaths
(ListIterator<String> paths) Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.void
toggleAs()
Toggles the usage of theAS
identifier.protected void
toTextInternal
(Appendable writer) Prints out a string representation of thisStateObject
, which should not be used to define atrue
string representation of a JPQL query but should be used for debugging purposes.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, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
addPropertyChangeListener, children, decorate, findIdentificationVariable, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, isDecorated, removePropertyChangeListener, setParent, toString, toText
-
Field Details
-
AS_PROPERTY
Notifies the visibility of theAS
identifier has changed.- See Also:
-
-
Constructor Details
-
CollectionMemberDeclarationStateObject
Creates a newCollectionMemberDeclarationStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
- Throws:
NullPointerException
- The given parent cannot benull
-
CollectionMemberDeclarationStateObject
public CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent, ListIterator<String> paths, boolean as, String identificationVariable) Creates a newCollectionMemberDeclarationStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
paths
- The segments that represent the collection-valued pathas
- Determine whether theAS
identifier is used or notidentificationVariable
- The identification variable declaring the collection-valued path- Throws:
NullPointerException
- The given parent cannot benull
-
CollectionMemberDeclarationStateObject
public CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent, ListIterator<String> paths, String identificationVariable) Creates a newCollectionMemberDeclarationStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
paths
- The segments that represent the collection-valued pathidentificationVariable
- The identification variable declaring the collection-valued path- Throws:
NullPointerException
- The given parent cannot benull
-
CollectionMemberDeclarationStateObject
public CollectionMemberDeclarationStateObject(SimpleFromClauseStateObject parent, String collectionValuedPath) Creates a newCollectionMemberDeclarationStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
collectionValuedPath
- The derived collection-valued path expression- Throws:
NullPointerException
- The given parent cannot benull
-
-
Method Details
-
accept
Description copied from interface:StateObject
Visits thisStateObject
by the givenvisitor
.- Specified by:
accept
in interfaceStateObject
- Parameters:
visitor
- Thevisitor
to visit this object
-
addAs
Makes sure theAS
identifier is specified.- Returns:
- This object
-
addChildren
Description copied from class:AbstractStateObject
Adds the children of thisStateObject
to the given list.- Overrides:
addChildren
in classAbstractStateObject
- Parameters:
children
- The list used to store the children
-
getCollectionValuedPath
Returns the model object representing the collection-valued association-field of an entity abstract schema type.- Returns:
- The collection-valued association-field of an entity abstract schema type
-
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 classAbstractStateObject
- 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)
-
getIdentificationVariable
Returns the model object representing an identification variable evaluating to a collection-valued association-field of an entity abstract schema type.- Returns:
- The identification variable portion of this declaration
-
getManagedType
Description copied from interface:VariableDeclarationStateObject
Returns theIManagedType
for the given identification variable. The search does not traverse up the query hierarchy if this declaration is for a subquery.
In the above query, the managed type associated with the identification variable:SELECT e FROM Department d JOIN KEY(d.employees).addresses a
- d is "Department"
- a is "Address"
- Specified by:
getManagedType
in interfaceVariableDeclarationStateObject
- Parameters:
stateObject
- TheStateObject
that should be an simple identification variable or an encapsulated identification variable with the identifierKEY
orVALUE
- Returns:
- The
IManagedType
representing the domain object declared by the given identification variable
-
getParent
Description copied from interface:StateObject
Returns the parent of thisStateObject
.- Specified by:
getParent
in interfaceStateObject
- Overrides:
getParent
in classAbstractStateObject
- Returns:
- Returns the parent of this
StateObject
, which isnull
only when this is the root of the hierarchy
-
hasAs
public boolean hasAs()Determines whether theAS
identifier is used or not.- Returns:
true
if theAS
identifier is part of the expression;false
otherwise
-
hasIdentificationVariable
public boolean hasIdentificationVariable()Determines whether an identification variable was defined.- Returns:
true
if an identification variable is defined;false
otherwise
-
identificationVariables
Description copied from interface:VariableDeclarationStateObject
Returns theIdentificationVariableStateObject
that are used by this state object. It is possible more than one declaration exists, like a range variable declaration has also joins and join fetches.- Specified by:
identificationVariables
in interfaceVariableDeclarationStateObject
- Returns:
- The list of
IdentificationVariableStateObject
-
initialize
protected void initialize()Description copied from class:AbstractStateObject
Initializes this state object.- Overrides:
initialize
in classAbstractStateObject
-
isDerived
public boolean isDerived()Determines whether this collection member declaration is used as a derived collection-valued path expression.- Returns:
true
if this collection member declaration is used as this form: "IN collection_valued_path_expression
" in a subquery;false
if it's used as this form:IN(collection_valued_path_expression) [AS] identification_variable
" in a top-level or subquery queries
-
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 classAbstractStateObject
- Parameters:
stateObject
- TheStateObject
to compare its content to this one- Returns:
true
if both object are equivalent;false
otherwise
-
removeAs
public void removeAs()Makes sure theAS
identifier is not specified. -
setAs
public void setAs(boolean as) Sets whether theAS
identifier is used or not.- Parameters:
as
-true
if theAS
identifier is part of the expression;false
otherwise
-
setDerived
public void setDerived(boolean derived) Sets whether this collection member declaration is used as a derived collection-valued path expression.- Parameters:
derived
-true
if this collection member declaration is used as this form: "IN collection_valued_path_expression
" in a subquery;false
if it's used as this form:IN(collection_valued_path_expression) [AS] identification_variable
" in a top-level or subquery queries
-
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 anIN
expression
-
setIdentificationVariable
Sets the new identification variable that will range over the collection-valued path.- Parameters:
identificationVariable
- The new identification variable
-
setPath
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.- Parameters:
path
- The new path expression
-
setPaths
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.- Parameters:
paths
- The new path expression
-
setPaths
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.- Parameters:
paths
- The new path expression
-
setPaths
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.- Parameters:
paths
- The new path expression
-
toggleAs
public void toggleAs()Toggles the usage of theAS
identifier. -
toTextInternal
Description copied from class:AbstractStateObject
Prints out a string representation of thisStateObject
, which should not be used to define atrue
string representation of a JPQL query but should be used for debugging purposes.- Specified by:
toTextInternal
in classAbstractStateObject
- Parameters:
writer
- The writer used to print out the string representation- Throws:
IOException
- This should never happens, it is only required becauseAppendable
is used instead of any concrete class
-