Class AbstractFromClauseStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject<VariableDeclarationStateObject>
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractFromClauseStateObject
- All Implemented Interfaces:
DeclarationStateObject
,ListHolderStateObject<VariableDeclarationStateObject>
,StateObject
- Direct Known Subclasses:
FromClauseStateObject
,SimpleFromClauseStateObject
public abstract class AbstractFromClauseStateObject
extends AbstractListHolderStateObject<VariableDeclarationStateObject>
implements DeclarationStateObject
This state object represents the abstract definition of a
FROM
clause, which
is either the FROM
clause of the query or of a sub-query expression.- Since:
- 2.4
- Version:
- 2.5
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Notifies the content of the list ofVariableDeclarationStateObject
has changed. -
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a newAbstractFromClauseStateObject
. -
Method Summary
Modifier and TypeMethodDescriptionAdds a new collection declaration to theFROM
clause.addCollectionDeclaration
(String collectionValuedPath, String identificationVariable) Adds a new collection declaration to theFROM
clause.protected void
addProblems
(List<Problem> currentProblems) Adds to the given list the problems that were found with the current state of thisStateObject
, which means there are validation issues.Adds a new range variable declaration to theFROM
clause.addRangeDeclaration
(String entityName, String identificationVariable) Adds a new range variable declaration.addRangeDeclaration
(IEntity entity, String identificationVariable) Adds to this select statement a new range variable declaration.protected abstract String
Returns the BNF of the declaration part of this clause.ListIterable
<? extends VariableDeclarationStateObject> Returns the list of declarations declared in the declaration clause of the current query.findIdentificationVariable
(String variable) Returns theIdentificationVariableStateObject
representing the given identification variable.Returns the declaration clause which defines the domain of the query by declaring identification variables.Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.getManagedType
(StateObject stateObject) Returns theIManagedType
for the given identification variable.Returns the parent of thisStateObject
.Returns theIdentificationVariableStateObjects
holding onto the identification variables, which are the variables defined in theFROM
clause.boolean
isEquivalent
(StateObject stateObject) Determines whether the givenStateObject
is equivalent to this one, i.e.protected String
listName()
Returns the name that is uniquely identifying the list.void
Parses the given JPQL fragment and create the select item.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.AbstractListHolderStateObject
addChildren, addItem, addItems, addListChangeListener, areChildrenEquivalent, canMoveDown, canMoveUp, getItem, hasItems, initialize, items, itemsSize, moveDown, moveUp, removeItem, removeItems, removeListChangeListener, toStringItems
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, firePropertyChanged, getChangeSupport, 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.DeclarationStateObject
findManagedType
Methods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
accept, addPropertyChangeListener, children, decorate, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, isDecorated, removePropertyChangeListener, setParent, toString, toText
-
Field Details
-
VARIABLE_DECLARATIONS_LIST
Notifies the content of the list ofVariableDeclarationStateObject
has changed.- See Also:
-
-
Constructor Details
-
AbstractFromClauseStateObject
Creates a newAbstractFromClauseStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
- Throws:
NullPointerException
- The given parent cannot benull
-
-
Method Details
-
addCollectionDeclaration
Adds a new collection declaration to theFROM
clause.- Returns:
- The
CollectionMemberDeclarationStateObject
representing the collection declaration
-
addCollectionDeclaration
public CollectionMemberDeclarationStateObject addCollectionDeclaration(String collectionValuedPath, String identificationVariable) Adds a new collection declaration to theFROM
clause.- Parameters:
collectionValuedPath
- The collection-valued path expressionidentificationVariable
- The variable defining the collection-valued path expression- Returns:
- The
CollectionMemberDeclarationStateObject
representing the collection declaration
-
addProblems
Description copied from class:AbstractStateObject
Adds to the given list the problems that were found with the current state of thisStateObject
, which means there are validation issues.- Overrides:
addProblems
in classAbstractStateObject
- Parameters:
currentProblems
- The list to which the problems are added
-
addRangeDeclaration
Adds a new range variable declaration to theFROM
clause.- Returns:
- The
StateObject
representing the range variable declaration
-
addRangeDeclaration
public IdentificationVariableDeclarationStateObject addRangeDeclaration(IEntity entity, String identificationVariable) Adds to this select statement a new range variable declaration.- Parameters:
entity
- The external form of the entity to add to the declaration listidentificationVariable
- The unique identifier identifying the abstract schema name- Returns:
- The state object of the new declaration
-
addRangeDeclaration
public IdentificationVariableDeclarationStateObject addRangeDeclaration(String entityName, String identificationVariable) Adds a new range variable declaration.- Parameters:
entityName
- The name of the entity nameidentificationVariable
- The new identification variable- Returns:
- The state object of the new declaration
-
declarationBNF
Returns the BNF of the declaration part of this clause.- Returns:
- The BNF of the declaration part of this clause
-
declarations
Description copied from interface:DeclarationStateObject
Returns the list of declarations declared in the declaration clause of the current query.- Specified by:
declarations
in interfaceDeclarationStateObject
- Returns:
- The list of
VariableDeclarationStateObject
that define the domain of the query
-
findIdentificationVariable
Description copied from interface:StateObject
Returns theIdentificationVariableStateObject
representing the given identification variable.- Specified by:
findIdentificationVariable
in interfaceStateObject
- Overrides:
findIdentificationVariable
in classAbstractStateObject
- Parameters:
variable
- The name of the identification variable to retrieve its state object- Returns:
- The
IdentificationVariableStateObject
defining the given identification variable
-
getDeclaration
Description copied from interface:StateObject
Returns the declaration clause which defines the domain of the query by declaring identification variables.- Specified by:
getDeclaration
in interfaceStateObject
- Overrides:
getDeclaration
in classAbstractStateObject
- Returns:
- The declaration clause of which this
StateObject
is a child; i.e. either the top-level declaration if this is part of the top query or the sub-level declaration if this is part of a subquery
-
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)
-
getManagedType
Description copied from interface:DeclarationStateObject
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 interfaceDeclarationStateObject
- 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 - See Also:
-
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
-
identificationVariables
Returns theIdentificationVariableStateObjects
holding onto the identification variables, which are the variables defined in theFROM
clause.Example:
Employee e
; e is returnedIN (e.employees) AS emps
; emps is returnedManager m JOIN m.employees emps
; m and emps are returned
- Returns:
- The list of
IdentificationVariableStateObjects
-
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
-
listName
Description copied from class:AbstractListHolderStateObject
Returns the name that is uniquely identifying the list.- Specified by:
listName
in classAbstractListHolderStateObject<VariableDeclarationStateObject>
- Returns:
- The unique name identifying the list
-
parse
Parses the given JPQL fragment and create the select item. For the top-level query, the fragment can contain several select items but for a subquery, it can represent only one.- Parameters:
jpqlFragment
- The portion of the query representing one or several select items
-
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
-