Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.tools.model.query

public Class JoinStateObject

extends AbstractStateObject
Class Inheritance
Annotations
@SuppressWarnings:nls, unused
Imports
java.io.IOException, java.util.List, .ListIterator, org.eclipse.persistence.jpa.jpql.Assert, org.eclipse.persistence.jpa.jpql.parser.Join, org.eclipse.persistence.jpa.jpql.utility.iterable.ListIterable

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

Author
Pascal Filion
Since
2.4
Version
2.4
See Also
Join

Field Summary

Modifier and TypeField and Description
private boolean
as

Flag used to determine if the AS identifier is used or not.

public static final String
AS_PROPERTY

Notifies the visibility of the AS identifier has changed.

private IdentificationVariableStateObject
identificationVariable

The state object holding the identification variable.

public static final String
JOIN_TYPE_PROPERTY

Notifies the join type property has changed.

private CollectionValuedPathExpressionStateObject
joinAssociationPath

The state object holding the join association path.

private String
joinType

One of the joining types used by this state object.

Constructor Summary

AccessConstructor and Description
public
JoinStateObject(AbstractIdentificationVariableDeclarationStateObject
The parent of this state object
parent
,
String
One of the joining types
joinType
)

Creates a new JoinStateObject.

public
JoinStateObject(AbstractIdentificationVariableDeclarationStateObject
The parent of this state object
parent
,
String
One of the joining types
joinType
,
boolean
Determine whether the AS identifier is used or not
as
)

Creates a new JoinStateObject.

Method Summary

Modifier and TypeMethod and Description
public void
public JoinStateObject

Returns:

This object
addAs
()

Makes sure the AS identifier is specified.

protected void
addChildren(List<StateObject>
The list used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Adds the children of this StateObject to the given list.
public void
addJoinAssociationPaths(List<String>
The new path expression
paths
)

Adds the given segments to the end of the join association path expression.

public Join
getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
public String

Returns:

The variable defining the join association path
getIdentificationVariable
()

Returns the name of the identification variable that defines the join association path.

public IdentificationVariableStateObject

Returns:

The portion of the joining expression representing the identification variable
getIdentificationVariableStateObject
()

Returns the state object holding the identification variable.

public StateObject

Returns:

The root of the path expression
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.

public CollectionValuedPathExpressionStateObject

Returns:

The state object representing the join association path
getJoinAssociationPathStateObject
()

Returns the CollectionValuedPathExpressionStateObject representing the join association path.

public String

Returns:

The joining type of this joining expression
getJoinType
()

Returns the joining type.

public AbstractIdentificationVariableDeclarationStateObject
public boolean

Returns:

true if the AS identifier is part of the expression; false otherwise
hasAs
()

Determines whether the AS identifier is used or not.

public boolean

Returns:

true if the identifier FETCH was parsed; false otherwise
hasFetch
()

Determines whether the identifier FETCH was parsed.

public boolean

Returns:

true if the identification has been defined; false otherwise
hasIdentificationVariable
()

Determines whether the identification variable has been defined.

protected void
public boolean
isEquivalent(StateObject
The StateObject to compare its content to this one
stateObject
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
public ListIterable<String>

Returns:

An Iterator over the segments of the state field path
joinAssociationPaths
()

Returns the segments in the state field path in order.

public int

Returns:

The number of segments
joinAssociationPathSize
()

Returns the number of segments in the path expression.

public void
removeNot()

Makes sure the AS identifier is not specified.

public void
setAs(boolean
true if the AS identifier is part of the expression; false otherwise
as
)

Sets whether the AS identifier is used or not.

public void
setExpression(Join
The parsed object representing a JOIN expression
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.

public void
setIdentificationVariable(String
The new variable defining the join association path
identificationVariable
)

Sets the name of the identification variable that defines the join association path.

public void
setJoinAssociationIdentificationVariable(StateObject
The root of the path expression
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.

public void
setJoinAssociationPath(String
The new path expression
path
)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

public void
setJoinAssociationPaths(ListIterator<String>
The new path expression
paths
)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

public void
setJoinAssociationPaths(String[]
The new path expression
paths
)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

public void
setJoinType(String
One of the joining types
joinType
)

Sets the joining type.

public void
toggleAs()

Toggles the usage of the AS identifier.

protected void
toTextInternal(Appendable
The writer used to print out the string representation
writer
)

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

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(String
One of the possible joining types
joinType
)

Validates the given join type.

Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject:
acceptUnknownVisitoracceptUnknownVisitoraddProblemsaddPropertyChangeListenerareEquivalentbuildProblembuildProblembuildStateObjectbuildStateObjectscheckParentchildrendecorateequalsfindIdentificationVariablefirePropertyChangedgetChangeSupportgetDeclarationgetDecoratorgetGrammargetManagedTypeProvidergetQueryBuildergetRootgetTypegetTypegetTypeHelpergetTypeRepositoryhashCodeisDecoratedparentparentparentremovePropertyChangeListenersetExpressionsetParenttoStringtoStringtoStringInternaltoStringItemstoText

Field Detail

asback to summary
private boolean as

Flag used to determine if the AS identifier is used or not.

AS_PROPERTYback to summary
public static final String AS_PROPERTY

Notifies the visibility of the AS identifier has changed.

identificationVariableback to summary
private IdentificationVariableStateObject identificationVariable

The state object holding the identification variable.

JOIN_TYPE_PROPERTYback to summary
public static final String JOIN_TYPE_PROPERTY

Notifies the join type property has changed.

joinAssociationPathback to summary
private CollectionValuedPathExpressionStateObject joinAssociationPath

The state object holding the join association path.

joinTypeback to summary
private String joinType

One of the joining types used by this state object.

Constructor Detail

JoinStateObjectback to summary
public JoinStateObject(AbstractIdentificationVariableDeclarationStateObject parent, String joinType)

Creates a new JoinStateObject.

Parameters
parent:AbstractIdentificationVariableDeclarationStateObject

The parent of this state object

joinType:String

One of the joining types

JoinStateObjectback to summary
public JoinStateObject(AbstractIdentificationVariableDeclarationStateObject parent, String joinType, boolean as)

Creates a new JoinStateObject.

Parameters
parent:AbstractIdentificationVariableDeclarationStateObject

The parent of this state object

joinType:String

One of the joining types

as:boolean

Determine whether the AS identifier is used or not

Method Detail

acceptback to summary
public void accept(StateObjectVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.accept.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.accept.

Visits this StateObject by the given visitor.

Parameters
visitor:StateObjectVisitor

The visitor to visit this object

Annotations
@Override
addAsback to summary
public JoinStateObject addAs()

Makes sure the AS identifier is specified.

Returns:JoinStateObject

This object

addChildrenback to summary
protected void addChildren(List<StateObject> children)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Adds the children of this StateObject to the given list.

Parameters
children:List<StateObject>

The list used to store the children

Annotations
@Override
addJoinAssociationPathsback to summary
public void addJoinAssociationPaths(List<String> paths)

Adds the given segments to the end of the join association path expression. The identification variable will not be affected.

Parameters
paths:List<String>

The new path expression

getExpressionback to summary
public Join getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.

Returns:Join

The parsed object when a JPQL query is parsed and converted into a StateObject or null when the JPQL query is manually created (i.e. not from a string)

Annotations
@Override
getIdentificationVariableback to summary
public String getIdentificationVariable()

Returns the name of the identification variable that defines the join association path.

Returns:String

The variable defining the join association path

getIdentificationVariableStateObjectback to summary
public IdentificationVariableStateObject getIdentificationVariableStateObject()

Returns the state object holding the identification variable.

Returns:IdentificationVariableStateObject

The portion of the joining expression representing the identification variable

getJoinAssociationIdentificationVariableback to summary
public 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.

Returns:StateObject

The root of the path expression

getJoinAssociationPathStateObjectback to summary
public CollectionValuedPathExpressionStateObject getJoinAssociationPathStateObject()

Returns the CollectionValuedPathExpressionStateObject representing the join association path.

Returns:CollectionValuedPathExpressionStateObject

The state object representing the join association path

getJoinTypeback to summary
public String getJoinType()

Returns the joining type.

Returns:String

The joining type of this joining expression

getParentback to summary
public AbstractIdentificationVariableDeclarationStateObject getParent()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getParent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getParent.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getParent.

Returns the parent of this StateObject.

Returns:AbstractIdentificationVariableDeclarationStateObject

Returns the parent of this StateObject, which is null only when this is the root of the hierarchy

Annotations
@Override
hasAsback to summary
public boolean hasAs()

Determines whether the AS identifier is used or not.

Returns:boolean

true if the AS identifier is part of the expression; false otherwise

hasFetchback to summary
public boolean hasFetch()

Determines whether the identifier FETCH was parsed.

Returns:boolean

true if the identifier FETCH was parsed; false otherwise

hasIdentificationVariableback to summary
public boolean hasIdentificationVariable()

Determines whether the identification variable has been defined.

Returns:boolean

true if the identification has been defined; false otherwise

initializeback to summary
protected void initialize()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.initialize.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.initialize.

Initializes this state object.

Annotations
@Override
isEquivalentback to summary
public boolean isEquivalent(StateObject stateObject)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.

Parameters
stateObject:StateObject

The StateObject to compare its content to this one

Returns:boolean

true if both object are equivalent; false otherwise

Annotations
@Override
joinAssociationPathsback to summary
public ListIterable<String> joinAssociationPaths()

Returns the segments in the state field path in order.

Returns:ListIterable<String>

An Iterator over the segments of the state field path

joinAssociationPathSizeback to summary
public int joinAssociationPathSize()

Returns the number of segments in the path expression.

Returns:int

The number of segments

removeNotback to summary
public void removeNot()

Makes sure the AS identifier is not specified.

setAsback to summary
public void setAs(boolean as)

Sets whether the AS identifier is used or not.

Parameters
as:boolean

true if the AS identifier is part of the expression; false otherwise

setExpressionback to summary
public 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.

Parameters
expression:Join

The parsed object representing a JOIN expression

setIdentificationVariableback to summary
public void setIdentificationVariable(String identificationVariable)

Sets the name of the identification variable that defines the join association path.

Parameters
identificationVariable:String

The new variable defining the join association path

setJoinAssociationIdentificationVariableback to summary
public 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.

Parameters
identificationVariable:StateObject

The root of the path expression

setJoinAssociationPathback to summary
public void setJoinAssociationPath(String path)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters
path:String

The new path expression

setJoinAssociationPathsback to summary
public void setJoinAssociationPaths(ListIterator<String> paths)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters
paths:ListIterator<String>

The new path expression

setJoinAssociationPathsback to summary
public void setJoinAssociationPaths(String[] paths)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters
paths:String[]

The new path expression

setJoinTypeback to summary
public void setJoinType(String joinType)

Sets the joining type.

Parameters
joinType:String

One of the joining types

toggleAsback to summary
public void toggleAs()

Toggles the usage of the AS identifier.

toTextInternalback to summary
protected void toTextInternal(Appendable writer) throws IOException

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

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.

Parameters
writer:Appendable

The writer used to print out the string representation

Annotations
@Override
Exceptions
IOException:
This should never happens, it is only required because Appendable is used instead of any concrete class
validateJoinTypeback to summary
protected void validateJoinType(String joinType)

Validates the given join type.

Parameters
joinType:String

One of the possible joining types