Class SelectNode
- java.lang.Object
-
- org.eclipse.persistence.internal.jpa.parsing.Node
-
- org.eclipse.persistence.internal.jpa.parsing.MajorNode
-
- org.eclipse.persistence.internal.jpa.parsing.QueryNode
-
- org.eclipse.persistence.internal.jpa.parsing.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
-
-
Field Summary
-
Fields inherited from class org.eclipse.persistence.internal.jpa.parsing.Node
alias, left, right, shouldGenerateExpression
-
-
Constructor Summary
Constructors Constructor Description SelectNode()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyToQuery(DatabaseQuery theQuery, GenerationContext context)INTERNAL Apply this node to the passed queryDatabaseQuerycreateDatabaseQuery(ParseTreeContext context)Returns a DatabaseQuery instance representing the owning ParseTree.ExpressiongenerateExpression(GenerationContext context)Return a EclipseLink expression generated using the left node.java.util.ListgetIdentifiers()java.lang.ClassgetReferenceClass(GenerationContext context)Compute the Reference class for this query.java.util.ListgetSelectExpressions()booleanhasOneToOneSelected(GenerationContext context)booleanisSelected(java.lang.String variableName)Answer true if the variable name given as argument is SELECTed.booleanisSelectNode()booleanisVariableInINClauseSelected(GenerationContext context)Answer true if a variable in the IN clause is SELECTedbooleannodeRefersToObject(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 pNodequalifyAttributeAccess(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.java.lang.ClassresolveClass(GenerationContext context)Answer the class associated with my left node.voidsetDistinct(boolean distinct)voidsetIdentifiers(java.util.List identifiers)voidsetSelectExpressions(java.util.List exprs)booleanusesDistinct()voidvalidate(ParseTreeContext context)Validate node.voidverifySelectedAlias(GenerationContext context)Verify that the selected alias is a valid alias.-
Methods inherited from class org.eclipse.persistence.internal.jpa.parsing.QueryNode
getParseTree, isDeleteNode, isUpdateNode, setParseTree
-
Methods inherited from class org.eclipse.persistence.internal.jpa.parsing.MajorNode
getContext, setContext
-
Methods inherited from class org.eclipse.persistence.internal.jpa.parsing.Node
addToExpression, appendExpression, applyToQuery, getAlias, getAsString, getColumn, getLeft, getLine, getRight, getType, hasLeft, hasRight, isAggregateNode, isAliasableNode, isAttributeNode, isConstructorNode, isCountNode, isDivideNode, isDotNode, isEscape, isLiteralNode, isMapKeyNode, isMinusNode, isMultiplyNode, isNotNode, isParameterNode, isPlusNode, isSubqueryNode, isVariableNode, resolveAttribute, resolveClass, resolveMapping, resolveMapping, setAlias, setColumn, setLeft, setLine, setRight, setType, toString, toString, toStringDisplayName, toStringIndent, validateParameter
-
-
-
-
Method Detail
-
getSelectExpressions
public java.util.List getSelectExpressions()
-
setSelectExpressions
public void setSelectExpressions(java.util.List exprs)
-
getIdentifiers
public java.util.List getIdentifiers()
-
setIdentifiers
public void setIdentifiers(java.util.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:
createDatabaseQueryin classQueryNode
-
applyToQuery
public void applyToQuery(DatabaseQuery theQuery, GenerationContext context)
INTERNAL Apply this node to the passed query- Specified by:
applyToQueryin classQueryNode
-
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(java.lang.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"
-
isSelectNode
public boolean isSelectNode()
- Overrides:
isSelectNodein classQueryNode
-
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:
qualifyAttributeAccessin classNode
-
validate
public void validate(ParseTreeContext context)
Validate node.
-
resolveClass
public java.lang.Class resolveClass(GenerationContext context)
Answer the class associated with my left node.- Specified by:
resolveClassin classQueryNode
-
generateExpression
public Expression generateExpression(GenerationContext context)
Return a EclipseLink expression generated using the left node.- Specified by:
generateExpressionin classQueryNode
-
getReferenceClass
public java.lang.Class getReferenceClass(GenerationContext context)
Compute the Reference class for this query.- Overrides:
getReferenceClassin classQueryNode- Returns:
- the class this query is querying for
-
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
-
-