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 acollection_member_declarationranges 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 identifierIN. The argument to theINoperator 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:orcollection_member_declaration ::= IN(collection_valued_path_expression) [AS] identification_variableBNF:derived_collection_member_declaration ::= IN superquery_identification_variable.{single_valued_object_field.}*collection_valued_field- Version:
- 2.5
- See Also:
FromClauseStateObject,CollectionMemberDeclaration- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAS_PROPERTYNotifies the visibility of theASidentifier has changed.
-
Constructor Summary
Constructors Constructor Description CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent)Creates a newCollectionMemberDeclarationStateObject.CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent, java.util.ListIterator<java.lang.String> paths, boolean as, java.lang.String identificationVariable)Creates a newCollectionMemberDeclarationStateObject.CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent, java.util.ListIterator<java.lang.String> paths, java.lang.String identificationVariable)Creates a newCollectionMemberDeclarationStateObject.CollectionMemberDeclarationStateObject(SimpleFromClauseStateObject parent, java.lang.String collectionValuedPath)Creates a newCollectionMemberDeclarationStateObject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(StateObjectVisitor visitor)Visits thisStateObjectby the givenvisitor.CollectionMemberDeclarationStateObjectaddAs()Makes sure theASidentifier is specified.protected voidaddChildren(java.util.List<StateObject> children)Adds the children of thisStateObjectto the given list.CollectionValuedPathExpressionStateObjectgetCollectionValuedPath()Returns the model object representing the collection-valued association-field of an entity abstract schema type.CollectionMemberDeclarationgetExpression()Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.IdentificationVariableStateObjectgetIdentificationVariable()Returns the model object representing an identification variable evaluating to a collection-valued association-field of an entity abstract schema type.IManagedTypegetManagedType(StateObject stateObject)Returns theIManagedTypefor the given identification variable.AbstractFromClauseStateObjectgetParent()Returns the parent of thisStateObject.booleanhasAs()Determines whether theASidentifier is used or not.booleanhasIdentificationVariable()Determines whether an identification variable was defined.ListIterable<IdentificationVariableStateObject>identificationVariables()Returns theIdentificationVariableStateObjectthat are used by this state object.protected voidinitialize()Initializes this state object.booleanisDerived()Determines whether this collection member declaration is used as a derived collection-valued path expression.booleanisEquivalent(StateObject stateObject)Determines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.voidremoveAs()Makes sure theASidentifier is not specified.voidsetAs(boolean as)Sets whether theASidentifier is used or not.voidsetDerived(boolean derived)Sets whether this collection member declaration is used as a derived collection-valued path expression.voidsetExpression(CollectionMemberDeclaration expression)Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.voidsetIdentificationVariable(java.lang.String identificationVariable)Sets the new identification variable that will range over the collection-valued path.voidsetPath(java.lang.String path)Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.voidsetPaths(java.lang.String... paths)Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.voidsetPaths(java.util.List<java.lang.String> paths)Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.voidsetPaths(java.util.ListIterator<java.lang.String> paths)Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.voidtoggleAs()Toggles the usage of theASidentifier.protected voidtoTextInternal(java.lang.Appendable writer)Prints out a string representation of thisStateObject, which should not be used to define atruestring 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 Detail
-
AS_PROPERTY
public static final java.lang.String AS_PROPERTY
Notifies the visibility of theASidentifier has changed.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CollectionMemberDeclarationStateObject
public CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent)
Creates a newCollectionMemberDeclarationStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
java.lang.NullPointerException- The given parent cannot benull
-
CollectionMemberDeclarationStateObject
public CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent, java.util.ListIterator<java.lang.String> paths, boolean as, java.lang.String identificationVariable)
Creates a newCollectionMemberDeclarationStateObject.- Parameters:
parent- The parent of this state object, which cannot benullpaths- The segments that represent the collection-valued pathas- Determine whether theASidentifier is used or notidentificationVariable- The identification variable declaring the collection-valued path- Throws:
java.lang.NullPointerException- The given parent cannot benull
-
CollectionMemberDeclarationStateObject
public CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent, java.util.ListIterator<java.lang.String> paths, java.lang.String identificationVariable)
Creates a newCollectionMemberDeclarationStateObject.- Parameters:
parent- The parent of this state object, which cannot benullpaths- The segments that represent the collection-valued pathidentificationVariable- The identification variable declaring the collection-valued path- Throws:
java.lang.NullPointerException- The given parent cannot benull
-
CollectionMemberDeclarationStateObject
public CollectionMemberDeclarationStateObject(SimpleFromClauseStateObject parent, java.lang.String collectionValuedPath)
Creates a newCollectionMemberDeclarationStateObject.- Parameters:
parent- The parent of this state object, which cannot benullcollectionValuedPath- The derived collection-valued path expression- Throws:
java.lang.NullPointerException- The given parent cannot benull
-
-
Method Detail
-
accept
public void accept(StateObjectVisitor visitor)
Visits thisStateObjectby the givenvisitor.- Specified by:
acceptin interfaceStateObject- Parameters:
visitor- Thevisitorto visit this object
-
addAs
public CollectionMemberDeclarationStateObject addAs()
Makes sure theASidentifier is specified.- Returns:
- This object
-
addChildren
protected void addChildren(java.util.List<StateObject> children)
Adds the children of thisStateObjectto the given list.- Overrides:
addChildrenin classAbstractStateObject- Parameters:
children- The list used to store the children
-
getCollectionValuedPath
public CollectionValuedPathExpressionStateObject 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
public CollectionMemberDeclaration getExpression()
Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpressionin interfaceStateObject- Overrides:
getExpressionin classAbstractStateObject- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObjectornullwhen the JPQL query is manually created (i.e. not from a string)
-
getIdentificationVariable
public IdentificationVariableStateObject 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
public IManagedType getManagedType(StateObject stateObject)
Returns theIManagedTypefor 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:
getManagedTypein interfaceVariableDeclarationStateObject- Parameters:
stateObject- TheStateObjectthat should be an simple identification variable or an encapsulated identification variable with the identifierKEYorVALUE- Returns:
- The
IManagedTyperepresenting the domain object declared by the given identification variable
-
getParent
public AbstractFromClauseStateObject getParent()
Returns the parent of thisStateObject.- Specified by:
getParentin interfaceStateObject- Overrides:
getParentin classAbstractStateObject- Returns:
- Returns the parent of this
StateObject, which isnullonly when this is the root of the hierarchy
-
hasAs
public boolean hasAs()
Determines whether theASidentifier is used or not.- Returns:
trueif theASidentifier is part of the expression;falseotherwise
-
hasIdentificationVariable
public boolean hasIdentificationVariable()
Determines whether an identification variable was defined.- Returns:
trueif an identification variable is defined;falseotherwise
-
identificationVariables
public ListIterable<IdentificationVariableStateObject> identificationVariables()
Returns theIdentificationVariableStateObjectthat 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:
identificationVariablesin interfaceVariableDeclarationStateObject- Returns:
- The list of
IdentificationVariableStateObject
-
initialize
protected void initialize()
Initializes this state object.- Overrides:
initializein classAbstractStateObject
-
isDerived
public boolean isDerived()
Determines whether this collection member declaration is used as a derived collection-valued path expression.- Returns:
trueif this collection member declaration is used as this form: "IN collection_valued_path_expression" in a subquery;falseif it's used as this form:IN(collection_valued_path_expression) [AS] identification_variable" in a top-level or subquery queries
-
isEquivalent
public boolean isEquivalent(StateObject stateObject)
Determines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.- Specified by:
isEquivalentin interfaceStateObject- Overrides:
isEquivalentin classAbstractStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
removeAs
public void removeAs()
Makes sure theASidentifier is not specified.
-
setAs
public void setAs(boolean as)
Sets whether theASidentifier is used or not.- Parameters:
as-trueif theASidentifier is part of the expression;falseotherwise
-
setDerived
public void setDerived(boolean derived)
Sets whether this collection member declaration is used as a derived collection-valued path expression.- Parameters:
derived-trueif this collection member declaration is used as this form: "IN collection_valued_path_expression" in a subquery;falseif it's used as this form:IN(collection_valued_path_expression) [AS] identification_variable" in a top-level or subquery queries
-
setExpression
public void setExpression(CollectionMemberDeclaration expression)
Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.- Parameters:
expression- Theparsed objectrepresenting anINexpression
-
setIdentificationVariable
public void setIdentificationVariable(java.lang.String identificationVariable)
Sets the new identification variable that will range over the collection-valued path.- Parameters:
identificationVariable- The new identification variable
-
setPath
public void setPath(java.lang.String path)
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
public void setPaths(java.util.List<java.lang.String> paths)
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
public void setPaths(java.util.ListIterator<java.lang.String> paths)
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
public void setPaths(java.lang.String... paths)
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 theASidentifier.
-
toTextInternal
protected void toTextInternal(java.lang.Appendable writer) throws java.io.IOExceptionPrints out a string representation of thisStateObject, which should not be used to define atruestring representation of a JPQL query but should be used for debugging purposes.- Specified by:
toTextInternalin classAbstractStateObject- Parameters:
writer- The writer used to print out the string representation- Throws:
java.io.IOException- This should never happens, it is only required becauseAppendableis used instead of any concrete class
-
-