public class JoinStateObject extends AbstractStateObject
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.
join ::= join_spec join_association_path_expression [AS] identification_variableA 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.
fetch_join ::= join_spec FETCH join_association_path_expressionJoin| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
AS_PROPERTY
Notifies the visibility of the
AS identifier has changed. |
static java.lang.String |
JOIN_TYPE_PROPERTY
Notifies the join type property has changed.
|
| Constructor and Description |
|---|
JoinStateObject(AbstractIdentificationVariableDeclarationStateObject parent,
java.lang.String joinType)
Creates a new
JoinStateObject. |
JoinStateObject(AbstractIdentificationVariableDeclarationStateObject parent,
java.lang.String joinType,
boolean as)
Creates a new
JoinStateObject. |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(StateObjectVisitor visitor)
Visits this
StateObject by the given visitor. |
JoinStateObject |
addAs()
Makes sure the
AS identifier is specified. |
protected void |
addChildren(java.util.List<StateObject> children)
Adds the children of this
StateObject to the given list. |
void |
addJoinAssociationPaths(java.util.List<java.lang.String> paths)
Adds the given segments to the end of the join association path expression.
|
Join |
getExpression()
Returns the actual parsed object if this
StateObject representation of the JPQL query
was created by parsing an existing JPQL query. |
java.lang.String |
getIdentificationVariable()
Returns the name of the identification variable that defines the join association path.
|
IdentificationVariableStateObject |
getIdentificationVariableStateObject()
Returns the state object holding the identification variable.
|
StateObject |
getJoinAssociationIdentificationVariable()
Returns the
StateObject representing the identification variable that starts the path
expression, which can be a sample identification variable, a map value, map key or map entry
expression. |
CollectionValuedPathExpressionStateObject |
getJoinAssociationPathStateObject()
Returns the
CollectionValuedPathExpressionStateObject representing the join
association path. |
java.lang.String |
getJoinType()
Returns the joining type.
|
AbstractIdentificationVariableDeclarationStateObject |
getParent()
Returns the parent of this
StateObject. |
boolean |
hasAs()
Determines whether the
AS identifier is used or not. |
boolean |
hasFetch()
Determines whether the identifier FETCH was parsed.
|
boolean |
hasIdentificationVariable()
Determines whether the identification variable has been defined.
|
protected void |
initialize()
Initializes this state object.
|
boolean |
isEquivalent(StateObject stateObject)
Determines whether the given
StateObject is equivalent to this one, i.e. the
information of both StateObject is the same. |
ListIterable<java.lang.String> |
joinAssociationPaths()
Returns the segments in the state field path in order.
|
int |
joinAssociationPathSize()
Returns the number of segments in the path expression.
|
void |
removeNot()
Makes sure the
AS identifier is not specified. |
void |
setAs(boolean as)
Sets whether the
AS identifier is used or not. |
void |
setExpression(Join expression)
Keeps a reference of the
parsed object object, which should only be done when
this object is instantiated during the conversion of a parsed JPQL query into StateObjects. |
void |
setIdentificationVariable(java.lang.String identificationVariable)
Sets the name of the identification variable that defines the join association path.
|
void |
setJoinAssociationIdentificationVariable(StateObject identificationVariable)
Sets the
StateObject representing the identification variable that starts the path
expression, which can be a sample identification variable, a map value, map key or map entry
expression. |
void |
setJoinAssociationPath(java.lang.String path)
Changes the path expression with the list of segments, the identification variable will also
be updated with the first segment.
|
void |
setJoinAssociationPaths(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.
|
void |
setJoinAssociationPaths(java.lang.String[] paths)
Changes the path expression with the list of segments, the identification variable will also
be updated with the first segment.
|
void |
setJoinType(java.lang.String joinType)
Sets the joining type.
|
void |
toggleAs()
Toggles the usage of the
AS identifier. |
protected void |
toTextInternal(java.lang.Appendable writer)
Prints out a string representation of this
StateObject, which should not be used to
define a true string representation of a JPQL query but should be used for
debugging purposes. |
protected void |
validateJoinType(java.lang.String joinType)
Validates the given join type.
|
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, toTextpublic static final java.lang.String AS_PROPERTY
AS identifier has changed.public static final java.lang.String JOIN_TYPE_PROPERTY
public JoinStateObject(AbstractIdentificationVariableDeclarationStateObject parent, java.lang.String joinType)
JoinStateObject.parent - The parent of this state objectjoinType - One of the joining typespublic JoinStateObject(AbstractIdentificationVariableDeclarationStateObject parent, java.lang.String joinType, boolean as)
JoinStateObject.parent - The parent of this state objectjoinType - One of the joining typesas - Determine whether the AS identifier is used or notpublic void accept(StateObjectVisitor visitor)
StateObject by the given visitor.visitor - The visitor to visit this objectpublic JoinStateObject addAs()
AS identifier is specified.protected void addChildren(java.util.List<StateObject> children)
StateObject to the given list.addChildren in class AbstractStateObjectchildren - The list used to store the childrenpublic void addJoinAssociationPaths(java.util.List<java.lang.String> paths)
paths - The new path expressionpublic Join getExpression()
StateObject representation of the JPQL query
was created by parsing an existing JPQL query.getExpression in interface StateObjectgetExpression in class AbstractStateObjectStateObject
or null when the JPQL query is manually created (i.e. not from a string)public java.lang.String getIdentificationVariable()
public IdentificationVariableStateObject getIdentificationVariableStateObject()
public StateObject getJoinAssociationIdentificationVariable()
StateObject representing the identification variable that starts the path
expression, which can be a sample identification variable, a map value, map key or map entry
expression.public CollectionValuedPathExpressionStateObject getJoinAssociationPathStateObject()
CollectionValuedPathExpressionStateObject representing the join
association path.public java.lang.String getJoinType()
public AbstractIdentificationVariableDeclarationStateObject getParent()
StateObject.getParent in interface StateObjectgetParent in class AbstractStateObjectStateObject, which is null only when
this is the root of the hierarchypublic boolean hasAs()
AS identifier is used or not.true if the AS identifier is part of the expression;
false otherwisepublic boolean hasFetch()
true if the identifier FETCH was parsed; false otherwisepublic boolean hasIdentificationVariable()
true if the identification has been defined; false otherwiseprotected void initialize()
initialize in class AbstractStateObjectpublic boolean isEquivalent(StateObject stateObject)
StateObject is equivalent to this one, i.e. the
information of both StateObject is the same.isEquivalent in interface StateObjectisEquivalent in class AbstractStateObjectstateObject - The StateObject to compare its content to this onetrue if both object are equivalent; false otherwisepublic ListIterable<java.lang.String> joinAssociationPaths()
Iterator over the segments of the state field pathpublic int joinAssociationPathSize()
public void removeNot()
AS identifier is not specified.public void setAs(boolean as)
AS identifier is used or not.as - true if the AS identifier is part of the expression;
false otherwisepublic void setExpression(Join expression)
parsed object object, which should only be done when
this object is instantiated during the conversion of a parsed JPQL query into StateObjects.expression - The parsed object representing a JOIN
expressionpublic void setIdentificationVariable(java.lang.String identificationVariable)
identificationVariable - The new variable defining the join association pathpublic void setJoinAssociationIdentificationVariable(StateObject identificationVariable)
StateObject representing the identification variable that starts the path
expression, which can be a sample identification variable, a map value, map key or map entry
expression.identificationVariable - The root of the path expressionpublic void setJoinAssociationPath(java.lang.String path)
path - The new path expressionpublic void setJoinAssociationPaths(java.util.ListIterator<java.lang.String> paths)
paths - The new path expressionpublic void setJoinAssociationPaths(java.lang.String[] paths)
paths - The new path expressionpublic void setJoinType(java.lang.String joinType)
joinType - One of the joining typespublic void toggleAs()
AS identifier.protected void toTextInternal(java.lang.Appendable writer)
throws java.io.IOException
StateObject, which should not be used to
define a true string representation of a JPQL query but should be used for
debugging purposes.toTextInternal in class AbstractStateObjectwriter - The writer used to print out the string representationjava.io.IOException - This should never happens, it is only required because Appendable
is used instead of any concrete classprotected void validateJoinType(java.lang.String joinType)
joinType - One of the possible joining types