Class JoinStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.JoinStateObject
- All Implemented Interfaces:
StateObject
A
JOIN enables the fetching of an association as a side effect of the
execution of a query. A JOIN is specified over an entity and its related
entities.
BNF: join ::= join_spec join_association_path_expression [AS] identification_variable
A JOIN FETCH enables the fetching of an association as a side effect of the execution of a query. A JOIN FETCH is specified over an entity and its related entities.
BNF: fetch_join ::= join_spec FETCH join_association_path_expression
- Since:
- 2.4
- Version:
- 2.4
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJoinStateObject(AbstractIdentificationVariableDeclarationStateObject parent, String joinType) Creates a newJoinStateObject.JoinStateObject(AbstractIdentificationVariableDeclarationStateObject parent, String joinType, boolean as) Creates a newJoinStateObject. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(StateObjectVisitor visitor) Visits thisStateObjectby the givenvisitor.addAs()Makes sure theASidentifier is specified.protected voidaddChildren(List<StateObject> children) Adds the children of thisStateObjectto the given list.voidaddJoinAssociationPaths(List<String> paths) Adds the given segments to the end of the join association path expression.Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.Returns the name of the identification variable that defines the join association path.Returns the state object holding the identification variable.Returns theStateObjectrepresenting the identification variable that starts the path expression, which can be a sample identification variable, a map value, map key or map entry expression.Returns theCollectionValuedPathExpressionStateObjectrepresenting the join association path.Returns the joining type.Returns the parent of thisStateObject.booleanhasAs()Determines whether theASidentifier is used or not.booleanhasFetch()Determines whether the identifier FETCH was parsed.booleanDetermines whether the identification variable has been defined.protected voidInitializes this state object.booleanisEquivalent(StateObject stateObject) Determines whether the givenStateObjectis equivalent to this one, i.e.Returns the segments in the state field path in order.intReturns the number of segments in the path expression.voidMakes sure theASidentifier is not specified.voidsetAs(boolean as) Sets whether theASidentifier is used or not.voidsetExpression(Join 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(String identificationVariable) Sets the name of the identification variable that defines the join association path.voidsetJoinAssociationIdentificationVariable(StateObject identificationVariable) Sets theStateObjectrepresenting the identification variable that starts the path expression, which can be a sample identification variable, a map value, map key or map entry expression.voidsetJoinAssociationPath(String path) Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.voidsetJoinAssociationPaths(String[] paths) Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.voidChanges the path expression with the list of segments, the identification variable will also be updated with the first segment.voidsetJoinType(String joinType) Sets the joining type.voidtoggleAs()Toggles the usage of theASidentifier.protected voidtoTextInternal(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.protected voidvalidateJoinType(String joinType) Validates the given join type.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
-
Field Details
-
AS_PROPERTY
Notifies the visibility of theASidentifier has changed.- See Also:
-
JOIN_TYPE_PROPERTY
Notifies the join type property has changed.- See Also:
-
-
Constructor Details
-
JoinStateObject
public JoinStateObject(AbstractIdentificationVariableDeclarationStateObject parent, String joinType) Creates a newJoinStateObject.- Parameters:
parent- The parent of this state objectjoinType- One of the joining types
-
JoinStateObject
public JoinStateObject(AbstractIdentificationVariableDeclarationStateObject parent, String joinType, boolean as) Creates a newJoinStateObject.- Parameters:
parent- The parent of this state objectjoinType- One of the joining typesas- Determine whether theASidentifier is used or not
-
-
Method Details
-
accept
Description copied from interface:StateObjectVisits thisStateObjectby the givenvisitor.- Parameters:
visitor- Thevisitorto visit this object
-
addAs
Makes sure theASidentifier is specified.- Returns:
- This object
-
addChildren
Description copied from class:AbstractStateObjectAdds the children of thisStateObjectto the given list.- Overrides:
addChildrenin classAbstractStateObject- Parameters:
children- The list used to store the children
-
addJoinAssociationPaths
Adds the given segments to the end of the join association path expression. The identification variable will not be affected.- Parameters:
paths- The new path expression
-
getExpression
Description copied from interface:StateObjectReturns 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
Returns the name of the identification variable that defines the join association path.- Returns:
- The variable defining the join association path
-
getIdentificationVariableStateObject
Returns the state object holding the identification variable.- Returns:
- The portion of the joining expression representing the identification variable
-
getJoinAssociationIdentificationVariable
Returns theStateObjectrepresenting the identification variable that starts the path expression, which can be a sample identification variable, a map value, map key or map entry expression.- Returns:
- The root of the path expression
-
getJoinAssociationPathStateObject
Returns theCollectionValuedPathExpressionStateObjectrepresenting the join association path.- Returns:
- The state object representing the join association path
-
getJoinType
Returns the joining type.- Returns:
- The joining type of this joining expression
-
getParent
Description copied from interface:StateObjectReturns 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
-
hasFetch
public boolean hasFetch()Determines whether the identifier FETCH was parsed.- Returns:
trueif the identifier FETCH was parsed;falseotherwise
-
hasIdentificationVariable
public boolean hasIdentificationVariable()Determines whether the identification variable has been defined.- Returns:
trueif the identification has been defined;falseotherwise
-
initialize
protected void initialize()Description copied from class:AbstractStateObjectInitializes this state object.- Overrides:
initializein classAbstractStateObject
-
isEquivalent
Description copied from interface:StateObjectDetermines 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
-
joinAssociationPaths
Returns the segments in the state field path in order.- Returns:
- An
Iteratorover the segments of the state field path
-
joinAssociationPathSize
public int joinAssociationPathSize()Returns the number of segments in the path expression.- Returns:
- The number of segments
-
removeNot
public void removeNot()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
-
setExpression
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 aJOINexpression
-
setIdentificationVariable
Sets the name of the identification variable that defines the join association path.- Parameters:
identificationVariable- The new variable defining the join association path
-
setJoinAssociationIdentificationVariable
Sets theStateObjectrepresenting the identification variable that starts the path expression, which can be a sample identification variable, a map value, map key or map entry expression.- Parameters:
identificationVariable- The root of the path expression
-
setJoinAssociationPath
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
-
setJoinAssociationPaths
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
-
setJoinAssociationPaths
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
-
setJoinType
Sets the joining type.- Parameters:
joinType- One of the joining types
-
toggleAs
public void toggleAs()Toggles the usage of theASidentifier. -
toTextInternal
Description copied from class:AbstractStateObjectPrints 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:
IOException- This should never happens, it is only required becauseAppendableis used instead of any concrete class
-
validateJoinType
Validates the given join type.- Parameters:
joinType- One of the possible joining types
-