Class ParseTree
- java.lang.Object
-
- org.eclipse.persistence.internal.jpa.parsing.ParseTree
-
- Direct Known Subclasses:
JPQLParseTree
public class ParseTree extends java.lang.ObjectINTERNALPurpose: A ParseTree contains Node(s). This contains a root Node and provides traversal utilities.
Responsibilities:
- Add parameters to the query
- Generate an expression for the query
- Answer true if the tree has parameters
- Maintain the primary class name for the query
- Maintain the root of the parse tree
- Maintain the context for the parse tree
- Maintain the distinct state for the parse tree
- Print the contents of the parse tree on a string
- Since:
- TopLink 4.0
- Author:
- Jon Driscoll and Joel Lucuik
-
-
Constructor Summary
Constructors Constructor Description ParseTree()Return a new ParseTree.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGroupingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)INTERNAL Add the grouping to the passed queryvoidaddHavingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)INTERNAL Add the having to the passed queryvoidaddNonFetchJoinAttributes(ObjectLevelReadQuery theQuery, GenerationContext generationContext)INTERNALvoidaddOrderingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)INTERNAL Add the ordering to the passed queryvoidaddParametersToQuery(DatabaseQuery query)INTERNAL Add parameters to the queryvoidaddUpdatesToQuery(UpdateAllQuery theQuery, GenerationContext generationContext)INTERNAL Add the updates to the passed queryvoidadjustReferenceClassForQuery(DatabaseQuery theQuery, GenerationContext generationContext)INTERNAL Adjust the reference class of the passed query if necessary Need to test this for Employee, employee.getAddress(), report queryvoidapplyQueryNodeToQuery(DatabaseQuery theQuery, GenerationContext generationContext)INTERNAL Apply the select or update to the passed query.GenerationContextbuildContext(DatabaseQuery query, AbstractSession sessionForContext)INTERNAL Build the context to be used when generating the expression from the parse treeGenerationContextbuildContextForReadQuery(AbstractSession sessionForContext)INTERNAL Build the context to be used when generating the expression from the parse treeDatabaseQuerycreateDatabaseQuery()INTERNAL Returns a DatabaseQuery instance for this ParseTree.ExpressiongenerateExpression(DatabaseQuery readQuery, GenerationContext generationContext)INTERNAL Build a context for the expression generationjava.lang.ClassLoadergetClassLoader()INTERNAL Return a class loaderParseTreeContextgetContext()Return the context for this parse treeshortgetDistinctState()INTERNAL Return the DISTINCT state for the treeFromNodegetFromNode()INTERNAL Return the FROM NodeGroupByNodegetGroupByNode()INTERNAL Return the GroupByNodeHavingNodegetHavingNode()INTERNAL Return the HavingNodeOrderByNodegetOrderByNode()INTERNAL Return the OrderByNodeQueryNodegetQueryNode()INTERNAL Return the root node for the treejava.lang.ClassgetReferenceClass(DatabaseQuery query, GenerationContext generationContext)getReferenceClass(): Answer the class which will be the reference class for the query.SetNodegetSetNode()INTERNAL Return the set node for the treeWhereNodegetWhereNode()INTERNAL Return the Where nodebooleanhasGroupBy()INTERNAL Does this EJBQL have a Grouping ClausebooleanhasHaving()INTERNAL Does this EJBQL have a Having ClausebooleanhasOrderBy()INTERNAL Does this EJBQL have an Ordering ClausevoidinitBaseExpression(ModifyAllQuery theQuery, GenerationContext generationContext)INTERNAL Initialize the base expression in the generation context.voidinitBaseExpression(ObjectLevelReadQuery theQuery, GenerationContext generationContext)INTERNAL Initialize the base expression in the generation context.protected voidqualifyAttributeAccess(ParseTreeContext context)INTERNAL This method handles any unqualified field access in bulk UPDATE and DELETE statements.voidsetClassLoader(java.lang.ClassLoader loader)INTERNAL: Set the class loader for this parse treevoidsetContext(ParseTreeContext newContext)INTERNAL Set the context for this parse treevoidsetDistinctState(short newDistinctState)INTERNAL Set the DISTINCT state for the treevoidsetFromNode(FromNode fromNode)INTERNAL Set the FROM node for the queryvoidsetGroupByNode(GroupByNode newGroupByNode)INTERNAL Set the Group by nodevoidsetHavingNode(HavingNode newHavingNode)INTERNAL Set the Having nodevoidsetOrderByNode(OrderByNode newOrderByNode)INTERNAL Set the Order by nodevoidsetQueryNode(QueryNode newQueryNode)INTERNAL Set the Select nodevoidsetSelectionCriteriaForQuery(DatabaseQuery theQuery, GenerationContext generationContext)voidsetSetNode(SetNode newSetNode)INTERNAL Set the Where nodevoidsetWhereNode(WhereNode newWhereNode)INTERNAL Set the Where nodejava.lang.StringtoString()INTERNAL Print the contents of the parse tree on a stringbooleanusesDistinct()INTERNAL Answer true if DISTINCT has been chosen.voidvalidate(ParseTreeContext context)INTERNAL Validate the parse tree.voidvalidate(TypeHelper typeHelper)INTERNAL Validate the parse tree.protected voidvalidate(AbstractSession session, java.lang.ClassLoader classLoader)INTERNAL Validate the parse tree.voidverifySelect(DatabaseQuery theQuery, GenerationContext generationContext)INTERNAL Verify that the alias in the SELECT is valid.
-
-
-
Method Detail
-
createDatabaseQuery
public DatabaseQuery createDatabaseQuery()
INTERNAL Returns a DatabaseQuery instance for this ParseTree.
-
adjustReferenceClassForQuery
public void adjustReferenceClassForQuery(DatabaseQuery theQuery, GenerationContext generationContext)
INTERNAL Adjust the reference class of the passed query if necessary Need to test this for Employee, employee.getAddress(), report query
-
initBaseExpression
public void initBaseExpression(ObjectLevelReadQuery theQuery, GenerationContext generationContext)
INTERNAL Initialize the base expression in the generation context.
-
initBaseExpression
public void initBaseExpression(ModifyAllQuery theQuery, GenerationContext generationContext)
INTERNAL Initialize the base expression in the generation context.
-
validate
protected void validate(AbstractSession session, java.lang.ClassLoader classLoader)
INTERNAL Validate the parse tree.
-
validate
public void validate(TypeHelper typeHelper)
INTERNAL Validate the parse tree.
-
validate
public void validate(ParseTreeContext context)
INTERNAL Validate the parse tree.
-
qualifyAttributeAccess
protected void qualifyAttributeAccess(ParseTreeContext context)
INTERNAL This method handles any unqualified field access in bulk UPDATE and DELETE statements. A UPDATE or DELETE statement may not define an identification variable. In this case any field accessed from the current class is not qualified with an identification variable, e.g. UPDATE Customer SET name = :newname The method goes through the expressions of the SET clause and the WHERE clause of such an DELETE and UPDATE statement and qualifies the field access using the abstract schema name as qualifier.
-
addOrderingToQuery
public void addOrderingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)
INTERNAL Add the ordering to the passed query
-
addGroupingToQuery
public void addGroupingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)
INTERNAL Add the grouping to the passed query
-
addHavingToQuery
public void addHavingToQuery(ObjectLevelReadQuery theQuery, GenerationContext generationContext)
INTERNAL Add the having to the passed query
-
addNonFetchJoinAttributes
public void addNonFetchJoinAttributes(ObjectLevelReadQuery theQuery, GenerationContext generationContext)
INTERNAL
-
addUpdatesToQuery
public void addUpdatesToQuery(UpdateAllQuery theQuery, GenerationContext generationContext)
INTERNAL Add the updates to the passed query
-
addParametersToQuery
public void addParametersToQuery(DatabaseQuery query)
INTERNAL Add parameters to the query
-
applyQueryNodeToQuery
public void applyQueryNodeToQuery(DatabaseQuery theQuery, GenerationContext generationContext)
INTERNAL Apply the select or update to the passed query. If there is a single attribute being selected, add it to the query result set If an aggregate is being used, add it to the query result set
-
buildContext
public GenerationContext buildContext(DatabaseQuery query, AbstractSession sessionForContext)
INTERNAL Build the context to be used when generating the expression from the parse tree
-
buildContextForReadQuery
public GenerationContext buildContextForReadQuery(AbstractSession sessionForContext)
INTERNAL Build the context to be used when generating the expression from the parse tree
-
generateExpression
public Expression generateExpression(DatabaseQuery readQuery, GenerationContext generationContext)
INTERNAL Build a context for the expression generation
-
getContext
public ParseTreeContext getContext()
Return the context for this parse tree
-
getFromNode
public FromNode getFromNode()
INTERNAL Return the FROM Node
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
INTERNAL Return a class loader- Returns:
- java.lang.ClassLoader
-
getOrderByNode
public OrderByNode getOrderByNode()
INTERNAL Return the OrderByNode
-
getGroupByNode
public GroupByNode getGroupByNode()
INTERNAL Return the GroupByNode
-
getHavingNode
public HavingNode getHavingNode()
INTERNAL Return the HavingNode
-
getReferenceClass
public java.lang.Class getReferenceClass(DatabaseQuery query, GenerationContext generationContext)
getReferenceClass(): Answer the class which will be the reference class for the query. Resolve this using the node parsed from the "SELECT" of the EJBQL query string
-
getQueryNode
public QueryNode getQueryNode()
INTERNAL Return the root node for the tree
-
getSetNode
public SetNode getSetNode()
INTERNAL Return the set node for the tree
-
getWhereNode
public WhereNode getWhereNode()
INTERNAL Return the Where node
-
getDistinctState
public short getDistinctState()
INTERNAL Return the DISTINCT state for the tree
-
hasOrderBy
public boolean hasOrderBy()
INTERNAL Does this EJBQL have an Ordering Clause
-
hasGroupBy
public boolean hasGroupBy()
INTERNAL Does this EJBQL have a Grouping Clause
-
hasHaving
public boolean hasHaving()
INTERNAL Does this EJBQL have a Having Clause
-
setClassLoader
public void setClassLoader(java.lang.ClassLoader loader)
INTERNAL: Set the class loader for this parse tree- Parameters:
loader-
-
setContext
public void setContext(ParseTreeContext newContext)
INTERNAL Set the context for this parse tree
-
setFromNode
public void setFromNode(FromNode fromNode)
INTERNAL Set the FROM node for the query
-
setOrderByNode
public void setOrderByNode(OrderByNode newOrderByNode)
INTERNAL Set the Order by node
-
setGroupByNode
public void setGroupByNode(GroupByNode newGroupByNode)
INTERNAL Set the Group by node
-
setHavingNode
public void setHavingNode(HavingNode newHavingNode)
INTERNAL Set the Having node
-
setSelectionCriteriaForQuery
public void setSelectionCriteriaForQuery(DatabaseQuery theQuery, GenerationContext generationContext)
-
setQueryNode
public void setQueryNode(QueryNode newQueryNode)
INTERNAL Set the Select node
-
setSetNode
public void setSetNode(SetNode newSetNode)
INTERNAL Set the Where node
-
setWhereNode
public void setWhereNode(WhereNode newWhereNode)
INTERNAL Set the Where node
-
setDistinctState
public void setDistinctState(short newDistinctState)
INTERNAL Set the DISTINCT state for the tree
-
toString
public java.lang.String toString()
INTERNAL Print the contents of the parse tree on a string- Overrides:
toStringin classjava.lang.Object
-
verifySelect
public void verifySelect(DatabaseQuery theQuery, GenerationContext generationContext)
INTERNAL Verify that the alias in the SELECT is valid. Invalid: SELECT OBJECT(badAlias) FROM Employee employee.... Valid: SELECT OBJECT(employee) FROM Employee employee....
-
usesDistinct
public boolean usesDistinct()
INTERNAL Answer true if DISTINCT has been chosen.
-
-