Top Description Inners Fields Constructors Methods
org.eclipse.persistence.internal.jpa.jpql

public final Class HermesParser

extends Object
implements JPAQueryBuilder
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.queries.JPAQueryBuilder
Annotations
@SuppressWarnings:nls
Imports
java.text.MessageFormat, java.util.Collection, .LinkedList, .Map, .ResourceBundle, org.eclipse.persistence.config.ParserValidationType, org.eclipse.persistence.exceptions.JPQLException, org.eclipse.persistence.expressions.Expression, org.eclipse.persistence.internal.expressions.ParameterExpression, org.eclipse.persistence.internal.queries.JPQLCallQueryMechanism, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.jpa.jpql.EclipseLinkGrammarValidator, .JPQLQueryProblem, .JPQLQueryProblemResourceBundle, org.eclipse.persistence.jpa.jpql.parser.AbstractExpressionVisitor, .ConditionalExpressionBNF, .DefaultEclipseLinkJPQLGrammar, .DeleteStatement, .InputParameter, .JPQLExpression, .JPQLGrammar, .JPQLGrammar1_0, .JPQLGrammar2_0, .JPQLGrammar2_1, .JPQLGrammar2_2, .JPQLGrammar3_0, .JPQLGrammar3_1, .SelectStatement, .UpdateStatement, org.eclipse.persistence.queries.DatabaseQuery, .DatabaseQuery.ParameterType, .DeleteAllQuery, .JPAQueryBuilder, .ObjectLevelReadQuery, .ReadAllQuery, .ReportQuery, .UpdateAllQuery

This class compiles a JPQL query into a DatabaseQuery. If validation is not turned off, then the JPQL query will be validated based on the grammar related to the validation level and will also be validated based on the semantic (context).

The validation level determines how to validate the JPQL query. It checks if any specific feature is allowed. For instance, if the JPQL query has functions defined for EclipseLink grammar but the validation level is set for generic JPA, then an exception will be thrown indicating the function cannot be used.

Authors
John Bracken, Pascal Filion
See Also
JPQLExpression

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
HermesParser.DatabaseQueryVisitor

This visitor traverses the parsed tree and create the right EclipseLink query and populates it.

Field Summary

Modifier and TypeField and Description
private String
validationLevel

Determines how to validate the JPQL query grammatically.

Constructor Summary

AccessConstructor and Description
public
HermesParser()

Creates a new HermesParser.

Method Summary

Modifier and TypeMethod and Description
private void
addArguments(JPQLQueryContext
The JPQLQueryContext containing the information about the JPQL query
queryContext
,
DatabaseQuery
The EclipseLink DatabaseQuery where the input parameter types are added
databaseQuery
)

Registers the input parameters derived from the JPQL expression with the DatabaseQuery.

private JPQLException

Returns:

The JPQLException indicating the problems with the JPQL query
buildException
(JPQLQueryContext
The JPQLQueryContext containing the information about the JPQL query
queryContext
,
Collection<JPQLQueryProblem>
The problems found in the JPQL query that are translated into an exception
problems
,
String
The key used to retrieve the localized message
messageKey
)

Creates a JPQLException indicating the problems with the JPQL query.

public DatabaseQuery
buildQuery(CharSequence
A non-null string representation of the query to parse and to convert into a DatabaseQuery
jpqlQuery
,
AbstractSession
The EclipseLink AbstractSession that this query will execute against
session
)

Implements org.eclipse.persistence.queries.JPAQueryBuilder.buildQuery.

Creates a fully initialized DatabaseQuery by parsing the given JPQL query.
public Expression
buildSelectionCriteria(String
The name of the entity for which a criteria is created
entityName
,
String
The string representation of a conditional expression to parse
selectionCriteria
,
AbstractSession
The EclipseLink AbstractSession that this query will execute against
session
)

Implements org.eclipse.persistence.queries.JPAQueryBuilder.buildSelectionCriteria.

Creates a new Expression that represents the given selection criteria.
private JPQLException
private boolean

Returns:

true if the query might be incomplete or invalid; false if the query is complete and grammatically valid
isTolerant
()

Determines whether the JPQL query should be parsed with tolerance turned on or off, i.e. if validation is turned off, then it's assumed the JPQL query is grammatically valid and complete.

private JPQLGrammar

Returns:

The JPQLGrammar written for a specific JPA version or for the current version of EclipseLink
jpqlGrammar
()

Returns the JPQLGrammar that will help to validate the JPQL query grammatically and semantically (contextually).

public void
populateQuery(CharSequence
A non-null string representation of the query to parse and to convert into a DatabaseQuery
jpqlQuery
,
DatabaseQuery
The query to populate with the derived JPQL query
query
,
AbstractSession
The EclipseLink AbstractSession that this query will execute against
session
)

Implements org.eclipse.persistence.queries.JPAQueryBuilder.populateQuery.

Populates the given DatabaseQuery by parsing the given JPQL query.
private DatabaseQuery
private ResourceBundle
public void
setValidationLevel(String
The validation levels are defined in ParserValidationType
validationLevel
)

Implements org.eclipse.persistence.queries.JPAQueryBuilder.setValidationLevel.

Allow the parser validation level to be set.
private void
validate(JPQLQueryContext
The context used to query information about the application metadata and cached information
queryContext
,
Expression
The Expression to validate grammatically and semantically
expression
)

Grammatically and semantically validates the JPQL query.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

validationLevelback to summary
private String validationLevel

Determines how to validate the JPQL query grammatically.

Constructor Detail

HermesParserback to summary
public HermesParser()

Creates a new HermesParser.

Method Detail

addArgumentsback to summary
private void addArguments(JPQLQueryContext queryContext, DatabaseQuery databaseQuery)

Registers the input parameters derived from the JPQL expression with the DatabaseQuery.

Parameters
queryContext:JPQLQueryContext

The JPQLQueryContext containing the information about the JPQL query

databaseQuery:DatabaseQuery

The EclipseLink DatabaseQuery where the input parameter types are added

buildExceptionback to summary
private JPQLException buildException(JPQLQueryContext queryContext, Collection<JPQLQueryProblem> problems, String messageKey)

Creates a JPQLException indicating the problems with the JPQL query.

Parameters
queryContext:JPQLQueryContext

The JPQLQueryContext containing the information about the JPQL query

problems:Collection<JPQLQueryProblem>

The problems found in the JPQL query that are translated into an exception

messageKey:String

The key used to retrieve the localized message

Returns:JPQLException

The JPQLException indicating the problems with the JPQL query

buildQueryback to summary
public DatabaseQuery buildQuery(CharSequence jpqlQuery, AbstractSession session)

Implements org.eclipse.persistence.queries.JPAQueryBuilder.buildQuery.

Doc from org.eclipse.persistence.queries.JPAQueryBuilder.buildQuery.

Creates a fully initialized DatabaseQuery by parsing the given JPQL query.

Parameters
jpqlQuery:CharSequence

A non-null string representation of the query to parse and to convert into a DatabaseQuery

session:AbstractSession

The EclipseLink AbstractSession that this query will execute against

Returns:DatabaseQuery

The fully initialized DatabaseQuery

Annotations
@Override
buildSelectionCriteriaback to summary
public Expression buildSelectionCriteria(String entityName, String selectionCriteria, AbstractSession session)

Implements org.eclipse.persistence.queries.JPAQueryBuilder.buildSelectionCriteria.

Doc from org.eclipse.persistence.queries.JPAQueryBuilder.buildSelectionCriteria.

Creates a new Expression that represents the given selection criteria.

Parameters
entityName:String

The name of the entity for which a criteria is created

selectionCriteria:String

The string representation of a conditional expression to parse

session:AbstractSession

The EclipseLink AbstractSession that this query will execute against

Returns:Expression

The fully initialized Expression

Annotations
@Override
buildUnexpectedExceptionback to summary
private JPQLException buildUnexpectedException(CharSequence jpqlQuery, Exception exception)
isTolerantback to summary
private boolean isTolerant()

Determines whether the JPQL query should be parsed with tolerance turned on or off, i.e. if validation is turned off, then it's assumed the JPQL query is grammatically valid and complete. In this case, it will be parsed with tolerance turned off resulting in better performance.

Returns:boolean

true if the query might be incomplete or invalid; false if the query is complete and grammatically valid

jpqlGrammarback to summary
private JPQLGrammar jpqlGrammar()

Returns the JPQLGrammar that will help to validate the JPQL query grammatically and semantically (contextually). It will also checks if any specific feature added to that grammar is allowed. For instance, if the JPQL query has functions defined for EclipseLink grammar but the validation level is set for generic JPA, then an exception will be thrown.

Returns:JPQLGrammar

The JPQLGrammar written for a specific JPA version or for the current version of EclipseLink

populateQueryback to summary
public void populateQuery(CharSequence jpqlQuery, DatabaseQuery query, AbstractSession session)

Implements org.eclipse.persistence.queries.JPAQueryBuilder.populateQuery.

Doc from org.eclipse.persistence.queries.JPAQueryBuilder.populateQuery.

Populates the given DatabaseQuery by parsing the given JPQL query.

Parameters
jpqlQuery:CharSequence

A non-null string representation of the query to parse and to convert into a DatabaseQuery

query:DatabaseQuery

The query to populate with the derived JPQL query

session:AbstractSession

The EclipseLink AbstractSession that this query will execute against

Annotations
@Override
populateQueryImpback to summary
private DatabaseQuery populateQueryImp(CharSequence jpqlQuery, DatabaseQuery query, AbstractSession session)
resourceBundleback to summary
private ResourceBundle resourceBundle()
setValidationLevelback to summary
public void setValidationLevel(String validationLevel)

Implements org.eclipse.persistence.queries.JPAQueryBuilder.setValidationLevel.

Doc from org.eclipse.persistence.queries.JPAQueryBuilder.setValidationLevel.

Allow the parser validation level to be set.

Parameters
validationLevel:String

The validation levels are defined in ParserValidationType

Annotations
@Override
validateback to summary
private void validate(JPQLQueryContext queryContext, Expression expression)

Grammatically and semantically validates the JPQL query. If the query is not valid, then an exception will be thrown.

Parameters
queryContext:JPQLQueryContext

The context used to query information about the application metadata and cached information

expression:Expression

The Expression to validate grammatically and semantically

org.eclipse.persistence.internal.jpa.jpql back to summary

private Class HermesParser.DatabaseQueryVisitor

extends AbstractExpressionVisitor
Class Inheritance

This visitor traverses the parsed tree and create the right EclipseLink query and populates it.

Field Summary

Modifier and TypeField and Description
private final String
private final JPQLQueryContext

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private ReadAllQuery
private AbstractObjectLevelReadQueryVisitor
public void
public void
public void
public void
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpressionVisitor:
visitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisitvisit

Field Detail

jpqlQueryback to summary
private final String jpqlQuery
queryContextback to summary
private final JPQLQueryContext queryContext

Constructor Detail

DatabaseQueryVisitorback to summary
pack-priv DatabaseQueryVisitor(JPQLQueryContext queryContext, CharSequence jpqlQuery)

Method Detail

buildReadAllQueryback to summary
private ReadAllQuery buildReadAllQuery(SelectStatement expression)
buildVisitorback to summary
private AbstractObjectLevelReadQueryVisitor buildVisitor(ObjectLevelReadQuery query)
visitback to summary
public void visit(DeleteStatement expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpressionVisitor.visit.

Implements org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Doc from org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Visits the DeleteStatement expression.

Parameters
expression:DeleteStatement

The Expression to visit

Annotations
@Override
visitback to summary
public void visit(JPQLExpression expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpressionVisitor.visit.

Implements org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Doc from org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Visits the JPQLExpression expression.

Parameters
expression:JPQLExpression

The Expression to visit

Annotations
@Override
visitback to summary
public void visit(SelectStatement expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpressionVisitor.visit.

Implements org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Doc from org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Visits the SelectStatement expression.

Parameters
expression:SelectStatement

The Expression to visit

Annotations
@Override
visitback to summary
public void visit(UpdateStatement expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpressionVisitor.visit.

Implements org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Doc from org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor.visit.

Visits the UpdateStatement expression.

Parameters
expression:UpdateStatement

The UpdateStatement to visit

Annotations
@Override