Class SelectNode


  • public class SelectNode
    extends QueryNode
    INTERNAL:

    Purpose: Represent a SELECT

    Responsibilities:

    • Hold the distinct status
    • Modify a query based on the contents

    The SELECT statement determines the return type of an EJBQL query. The SELECT may also determine the distinct state of a query A SELECT can be one of the following:

      1. SELECT OBJECT(someObject)... This query will return a collection of objects
      2. SELECT anObject.anAttribute ... This will return a collection of anAttribute
      3. SELECT <aggregateFunction> ... This will return a single value
          The allowable aggregateFunctions are: AVG, COUNT, MAX, MIN, SUM
              SELECT AVG(emp.salary)... Returns the average of all the employees salaries
              SELECT COUNT(emp)... Returns a count of the employees
              SELECT COUNT(emp.firstName)... Returns a count of the employee's firstNames
              SELECT MAX(emp.salary)... Returns the maximum employee salary
              SELECT MIN(emp.salary)... Returns the minimum employee salary
              SELECT SUM(emp.salary)... Returns the sum of all the employees salaries
     
    Since:
    TopLink 5.0
    Author:
    Jon Driscoll
    • Constructor Detail

      • SelectNode

        public SelectNode()
    • Method Detail

      • getSelectExpressions

        public List getSelectExpressions()
      • setSelectExpressions

        public void setSelectExpressions​(List exprs)
      • getIdentifiers

        public List getIdentifiers()
      • setIdentifiers

        public void setIdentifiers​(List identifiers)
      • usesDistinct

        public boolean usesDistinct()
      • setDistinct

        public void setDistinct​(boolean distinct)
      • createDatabaseQuery

        public DatabaseQuery createDatabaseQuery​(ParseTreeContext context)
        Returns a DatabaseQuery instance representing the owning ParseTree. This implementation returns a ReadAllQuery for simple SELECT queries and a ReportQuery otherwise.
        Specified by:
        createDatabaseQuery in class QueryNode
      • hasOneToOneSelected

        public boolean hasOneToOneSelected​(GenerationContext context)
      • verifySelectedAlias

        public void verifySelectedAlias​(GenerationContext context)
        Verify that the selected alias is a valid alias. If it's not valid, an Exception will be thrown, likely JPQLException.aliasResolutionException. Valid: SELECT OBJECT(emp) FROM Employee emp WHERE ... Invalid: SELECT OBJECT(badAlias) FROM Employee emp WHERE ...
      • isSelected

        public boolean isSelected​(String variableName)
        Answer true if the variable name given as argument is SELECTed. True: "SELECT OBJECT(emp) ...." & variableName = "emp" False: "SELECT OBJECT(somethingElse) ..." & variableName = "emp"
      • qualifyAttributeAccess

        public Node qualifyAttributeAccess​(ParseTreeContext context)
        Check the select expression nodes for a path expression starting with a unqualified field access and if so, replace it by a qualified field access.
        Overrides:
        qualifyAttributeAccess in class Node
      • isVariableInINClauseSelected

        public boolean isVariableInINClauseSelected​(GenerationContext context)
        Answer true if a variable in the IN clause is SELECTed
      • nodeRefersToObject

        public boolean nodeRefersToObject​(Node node,
                                          GenerationContext context)
        Answer true if this node refers to an object described later in the EJBQL True: SELECT p FROM Project p False: SELECT p.id FROM Project p