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 aFROM
clause, which is either theFROM
clause of the query or of a sub-query expression.- Since:
- 2.4
- Version:
- 2.5
- Author:
- Pascal Filion
- See Also:
AbstractSelectStatementStateObject
,FromClauseStateObject
,AbstractFromClause
-
-
Field Summary
Fields Modifier and Type Field Description static String
VARIABLE_DECLARATIONS_LIST
Notifies the content of the list ofVariableDeclarationStateObject
has changed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CollectionMemberDeclarationStateObject
addCollectionDeclaration()
Adds a new collection declaration to theFROM
clause.CollectionMemberDeclarationStateObject
addCollectionDeclaration(String collectionValuedPath, String identificationVariable)
Adds a new collection declaration to theFROM
clause.IdentificationVariableDeclarationStateObject
addRangeDeclaration()
Adds a new range variable declaration to theFROM
clause.IdentificationVariableDeclarationStateObject
addRangeDeclaration(String entityName, String identificationVariable)
Adds a new range variable declaration.IdentificationVariableDeclarationStateObject
addRangeDeclaration(IEntity entity, String identificationVariable)
Adds to this select statement a new range variable declaration.ListIterable<? extends VariableDeclarationStateObject>
declarations()
Returns the list of declarations declared in the declaration clause of the current query.IdentificationVariableStateObject
findIdentificationVariable(String variable)
Returns theIdentificationVariableStateObject
representing the given identification variable.DeclarationStateObject
getDeclaration()
Returns the declaration clause which defines the domain of the query by declaring identification variables.AbstractFromClause
getExpression()
Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.IManagedType
getManagedType(StateObject stateObject)
Returns theIManagedType
for the given identification variable.AbstractSelectStatementStateObject
getParent()
Returns the parent of thisStateObject
.Iterable<IdentificationVariableStateObject>
identificationVariables()
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.void
parse(String jpqlFragment)
Parses the given JPQL fragment and create the select item.-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractListHolderStateObject
addItem, addItems, addListChangeListener, canMoveDown, canMoveUp, getItem, hasItems, items, itemsSize, moveDown, moveUp, removeItem, removeItems, removeListChangeListener
-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
addPropertyChangeListener, children, decorate, equals, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, removePropertyChangeListener, setExpression, setParent, toString, toString, toText
-
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 Detail
-
VARIABLE_DECLARATIONS_LIST
public static final String VARIABLE_DECLARATIONS_LIST
Notifies the content of the list ofVariableDeclarationStateObject
has changed.- See Also:
- Constant Field Values
-
-
Method Detail
-
addCollectionDeclaration
public CollectionMemberDeclarationStateObject 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
-
addRangeDeclaration
public IdentificationVariableDeclarationStateObject 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
-
declarations
public ListIterable<? extends VariableDeclarationStateObject> declarations()
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
public IdentificationVariableStateObject findIdentificationVariable(String variable)
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
public DeclarationStateObject getDeclaration()
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
public AbstractFromClause getExpression()
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
public IManagedType getManagedType(StateObject stateObject)
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:
DeclarationStateObject.findManagedType(StateObject)
-
getParent
public AbstractSelectStatementStateObject getParent()
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
public Iterable<IdentificationVariableStateObject> 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
public boolean isEquivalent(StateObject 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
-
parse
public void parse(String jpqlFragment)
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
-
-