java.lang.Object
org.eclipse.persistence.internal.jpa.parsing.ParseTree
Direct Known Subclasses:
JPQLParseTree

public class ParseTree extends Object
INTERNAL

Purpose: 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
  • Constructor Details

    • ParseTree

      public ParseTree()
      Return a new ParseTree.
  • Method Details

    • 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, 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 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 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(ClassLoader loader)
      INTERNAL: Set the class loader for this parse tree
    • 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 String toString()
      INTERNAL Print the contents of the parse tree on a string
      Overrides:
      toString in class 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.