Purpose: Represent a SELECT
Responsibilities:
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
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private List | |
| private List |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | applyToQuery(DatabaseQuery theQuery, GenerationContext context)
Implements abstract org. |
| public DatabaseQuery | createDatabaseQuery(ParseTreeContext context)
Implements abstract org. |
| public Expression | generateExpression(GenerationContext context)
Implements abstract org. |
| private Class | |
| private Node | |
| public List | |
| public Class | Returns: the class this query is querying forOverrides org. |
| public List | |
| public boolean | |
| private boolean | hasOneToOneSelected(Node node, GenerationContext context)
Answer true if there is a one-to-one relationship selected. |
| private boolean | isReadAllQuery(ParseTreeContext context)
Returns true if the SELECT clause consists of a single expression returning the base identification variable of the query and if the base variable is defined as a range variable w/o FETCH JOINs. |
| public boolean | |
| public boolean | |
| private boolean | |
| public boolean | isVariableInINClauseSelected(GenerationContext context)
Answer true if a variable in the IN clause is SELECTed |
| 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 |
| public Node | qualifyAttributeAccess(ParseTreeContext context)
Overrides org. |
| public Class | resolveClass(GenerationContext context)
Implements abstract org. |
| private boolean | selectingDirectToField(Node node, GenerationContext context)
Answer true if the SELECT ends in a direct-to-field. |
| private boolean | |
| public void | |
| public void | |
| public void | |
| public boolean | |
| public void | validate(ParseTreeContext context)
Overrides org. |
| public void |
| distinct | back to summary |
|---|---|
| private boolean distinct | |
| identifiers | back to summary |
|---|---|
| private List<String> identifiers | |
| selectExpressions | back to summary |
|---|---|
| private List<Node> selectExpressions | |
| SelectNode | back to summary |
|---|---|
| public SelectNode() | |
| applyToQuery | back to summary |
|---|---|
| public void applyToQuery(DatabaseQuery theQuery, GenerationContext context) Implements abstract org. INTERNAL Apply this node to the passed query
| |
| createDatabaseQuery | back to summary |
|---|---|
| public DatabaseQuery createDatabaseQuery(ParseTreeContext context) Implements abstract org. Returns a DatabaseQuery instance representing the owning ParseTree. This implementation returns a ReadAllQuery for simple SELECT queries and a ReportQuery otherwise.
| |
| generateExpression | back to summary |
|---|---|
| public Expression generateExpression(GenerationContext context) Implements abstract org. Return a EclipseLink expression generated using the left node.
| |
| getClassOfFirstVariable | back to summary |
|---|---|
| private Class | |
| getFirstSelectExpressionNode | back to summary |
|---|---|
| private Node getFirstSelectExpressionNode() Returns the first select expression node. | |
| getIdentifiers | back to summary |
|---|---|
| public List | |
| getReferenceClass | back to summary |
|---|---|
| public Class Overrides org. Compute the Reference class for this query. | |
| getSelectExpressions | back to summary |
|---|---|
| public List | |
| hasOneToOneSelected | back to summary |
|---|---|
| public boolean hasOneToOneSelected(GenerationContext context) | |
| hasOneToOneSelected | back to summary |
|---|---|
| private boolean hasOneToOneSelected(Node node, GenerationContext context) Answer true if there is a one-to-one relationship selected. This includes a chain of relationships. True: SELECT employee.address FROM ..... //Simple 1:1 True: SELECT a.b.c.d FROM ..... //where a->b, b->c and c->d are all 1:1. False: SELECT OBJECT(employee) FROM ..... //simple SELECT False: SELECT phoneNumber.areaCode FROM ..... //direct-to-field | |
| isReadAllQuery | back to summary |
|---|---|
| private boolean isReadAllQuery(ParseTreeContext context) Returns true if the SELECT clause consists of a single expression returning the base identification variable of the query and if the base variable is defined as a range variable w/o FETCH JOINs. | |
| isSelected | back to summary |
|---|---|
| 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" | |
| isSelectNode | back to summary |
|---|---|
| public boolean isSelectNode() Overrides org.
| |
| isSingleSelectExpression | back to summary |
|---|---|
| private boolean isSingleSelectExpression() | |
| isVariableInINClauseSelected | back to summary |
|---|---|
| public boolean isVariableInINClauseSelected(GenerationContext context) Answer true if a variable in the IN clause is SELECTed | |
| nodeRefersToObject | back to summary |
|---|---|
| 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 | |
| qualifyAttributeAccess | back to summary |
|---|---|
| public Node qualifyAttributeAccess(ParseTreeContext context) Overrides org. 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.
| |
| resolveClass | back to summary |
|---|---|
| public Class Implements abstract org. Answer the class associated with my left node.
| |
| selectingDirectToField | back to summary |
|---|---|
| private boolean selectingDirectToField(Node node, GenerationContext context) Answer true if the SELECT ends in a direct-to-field. true: SELECT phone.areaCode false: SELECT employee.address | |
| selectingRelationshipField | back to summary |
|---|---|
| private boolean selectingRelationshipField(Node node, GenerationContext context) | |
| setDistinct | back to summary |
|---|---|
| public void setDistinct(boolean distinct) | |
| setIdentifiers | back to summary |
|---|---|
| public void setIdentifiers(List<String> identifiers) | |
| setSelectExpressions | back to summary |
|---|---|
| public void setSelectExpressions(List<Node> exprs) | |
| usesDistinct | back to summary |
|---|---|
| public boolean usesDistinct() | |
| validate | back to summary |
|---|---|
| public void validate(ParseTreeContext context) Overrides org. Validate node.
| |
| verifySelectedAlias | back to summary |
|---|---|
| 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 ... | |