EclipseLink 2.5.0, build 'v20130507-3faac2b' API Reference

org.eclipse.persistence.jpa.jpql
Class AbstractEclipseLinkSemanticValidator

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor
      extended by org.eclipse.persistence.jpa.jpql.AbstractValidator
          extended by org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
              extended by org.eclipse.persistence.jpa.jpql.AbstractEclipseLinkSemanticValidator
All Implemented Interfaces:
EclipseLinkExpressionVisitor, ExpressionVisitor
Direct Known Subclasses:
EclipseLinkSemanticValidator

public class AbstractEclipseLinkSemanticValidator
extends AbstractSemanticValidator
implements EclipseLinkExpressionVisitor

This validator is responsible to gather the problems found in a JPQL query by validating the content to make sure it is semantically valid for EclipseLink. The grammar is not validated by this visitor.

For instance, the function AVG accepts a state field path. The property it represents has to be of numeric type. AVG(e.name) is parsable but is not semantically valid because the type of name is a string (the property signature is: "private String name").

Note: EclipseLink does not validate types, but leaves it to the database. This is because some databases such as Oracle allow different types to different functions and perform implicit type conversion. i.e. CONCAT('test', 2) returns 'test2'. Also the FUNC function has an unknown type, so should be allowed with any function.

Provisional API: This interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

Version:
2.5
See Also:
EclipseLinkGrammarValidator
Author:
Pascal Filion
Since:
2.4

Nested Class Summary
static class AbstractEclipseLinkSemanticValidator.EclipseLinkOwningClauseVisitor
          This visitor retrieves the clause owning the visited Expression.
protected static class AbstractEclipseLinkSemanticValidator.SubquerySelectItemCalculator
           
protected static class AbstractEclipseLinkSemanticValidator.TableExpressionVisitor
           
protected  class AbstractEclipseLinkSemanticValidator.TopLevelFirstDeclarationVisitor
           
 
Nested classes/interfaces inherited from class org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
AbstractSemanticValidator.CollectionValuedPathExpressionVisitor, AbstractSemanticValidator.ComparingEntityTypeLiteralVisitor, AbstractSemanticValidator.ComparisonExpressionVisitor, AbstractSemanticValidator.FirstDeclarationVisitor, AbstractSemanticValidator.PathType, AbstractSemanticValidator.StateFieldPathExpressionVisitor, AbstractSemanticValidator.SubqueryFirstDeclarationVisitor
 
Nested classes/interfaces inherited from class org.eclipse.persistence.jpa.jpql.AbstractValidator
AbstractValidator.BypassChildCollectionExpressionVisitor, AbstractValidator.BypassParentSubExpressionVisitor, AbstractValidator.ChildrenCollectorVisitor, AbstractValidator.JPQLQueryBNFValidator, AbstractValidator.NestedArrayVisitor, AbstractValidator.OwningClauseVisitor, AbstractValidator.OwningStatementVisitor, AbstractValidator.SubqueryVisitor
 
Field Summary
 
Fields inherited from class org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
collectionValuedPathExpressionVisitor, helper, registerIdentificationVariable, stateFieldPathExpressionVisitor, usedIdentificationVariables, virtualIdentificationVariableFinder
 
Constructor Summary
protected AbstractEclipseLinkSemanticValidator(SemanticValidatorHelper helper, EclipseLinkSemanticValidatorExtension extension)
          Creates a new AbstractEclipseLinkSemanticValidator.
 
Method Summary
protected  LiteralVisitor buildLiteralVisitor()
          Creates the visitor that can retrieve some information about various literal.
protected  AbstractValidator.OwningClauseVisitor buildOwningClauseVisitor()
          Creates the visitor that traverses the parent hierarchy of any Expression and stops at the first Expression that is a clause.
protected  AbstractEclipseLinkSemanticValidator.SubquerySelectItemCalculator buildSubquerySelectItemCalculator()
           
protected  AbstractEclipseLinkSemanticValidator.TableExpressionVisitor buildTableExpressionVisitor()
           
protected  AbstractEclipseLinkSemanticValidator.TopLevelFirstDeclarationVisitor buildTopLevelFirstDeclarationVisitor()
          
protected  JPQLQueryDeclaration getDeclaration(java.lang.String variableName)
           
protected  EclipseLinkSemanticValidatorExtension getExtension()
          Returns the extension that gives access to non-JPA metadata artifacts, such as database tables and columns.
protected  AbstractEclipseLinkSemanticValidator.SubquerySelectItemCalculator getSubquerySelectItemCalculator()
           
protected  AbstractEclipseLinkSemanticValidator.TableExpressionVisitor getTableExpressionVisitor()
           
protected  boolean isTableExpression(Expression expression)
           
protected  AbstractSemanticValidator.PathType selectClausePathExpressionPathType()
          Returns the type of path expression that is allowed in the SELECT clause.
protected  int subquerySelectItemCount(Expression subquery)
          Retrieves the number of select items the given subquery has.
protected  void validateFunctionExpression(FunctionExpression expression)
          Validates the given FunctionExpression.
protected  void validateInExpression(InExpression expression)
          Validates the given InExpression.
protected  void validateRangeVariableDeclarationRootObject(RangeVariableDeclaration expression)
          Validates the "root" object of the given RangeVariableDeclaration.
protected  java.lang.Boolean validateThirdPartyStateFieldPathExpression(StateFieldPathExpression expression)
          Validates the given StateFieldPathExpression, which means the path does not represent a mapping, or an enum constant.
protected  AbstractSemanticValidator.PathType validPathExpressionTypeForInExpression()
          Returns the type of path expression that is valid for the expression being tested by an IN expression; which is the left expression.
protected  AbstractSemanticValidator.PathType validPathExpressionTypeForStringExpression()
          Returns the type of path expression that is valid for a string expression; which is the left expression in a LIKE expression.
 void visit(AsOfClause expression)
          Visits the AsOfClause expression.
 void visit(CastExpression expression)
          Visits the CastExpression expression.
 void visit(ConnectByClause expression)
          Visits the ConnectByClause expression.
 void visit(DatabaseType expression)
          Visits the DatabaseType expression.
 void visit(ExtractExpression expression)
          Visits the ExtractExpression expression.
 void visit(HierarchicalQueryClause expression)
          Visits the HierarchicalQueryClause expression.
 void visit(OrderSiblingsByClause expression)
          Visits the OrderSiblingsByClause expression.
 void visit(RegexpExpression expression)
          Visits the RegexpExpression expression.
 void visit(StartWithClause expression)
          Visits the StartWithClause expression.
 void visit(TableExpression expression)
          Visits the TableExpression expression.
 void visit(TableVariableDeclaration expression)
          Visits the TableVariableDeclaration expression.
 void visit(UnionClause expression)
          Visits the UnionClause expression.
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
buildComparingEntityTypeLiteralVisitor, buildSubqueryFirstDeclarationVisitor, dispose, findVirtualIdentificationVariable, getCollectionValuedPathExpression, getCollectionValuedPathExpressionVisitor, getComparingEntityTypeLiteralVisitor, getComparisonExpressionVisitor, getGrammar, getStateFieldPathExpression, getStateFieldPathExpressionVisitor, getVirtualIdentificationVariableFinder, initialize, isComparingEntityTypeLiteral, isIdentificationVariableDeclaredAfter, isIdentificationVariableValidInComparison, isOrderComparison, isValid, subqueryFirstDeclarationVisitor, topLevelFirstDeclarationVisitor, updateStatus, validateAbsExpression, validateAbstractFromClause, validateAbstractSchemaName, validateAdditionExpression, validateAllOrAnyExpression, validateAndExpression, validateArithmeticExpression, validateArithmeticExpression, validateAvgFunction, validateBetweenExpression, validateCaseExpression, validateCoalesceExpression, validateCollectionMemberDeclaration, validateCollectionMemberExpression, validateCollectionValuedPathExpression, validateComparisonExpression, validateConcatExpression, validateConstructorExpression, validateCountFunction, validateDateTime, validateDeleteClause, validateDeleteStatement, validateDivisionExpression, validateEntityTypeLiteral, validateEntryExpression, validateExistsExpression, validateFirstDeclaration, validateFromClause, validateFunctionPathExpression, validateFunctionPathExpression, validateGroupByClause, validateHavingClause, validateIdentificationVariable, validateIdentificationVariable, validateIdentificationVariableDeclaration, validateIdentificationVariables, validateIndexExpression, validateJoin, validateJoinsIdentificationVariable, validateKeyExpression, validateLengthExpression, validateLikeExpression, validateLocateExpression, validateLowerExpression, validateMaxFunction, validateMinFunction, validateModExpression, validateMultiplicationExpression, validateNotExpression, validateNullComparisonExpression, validateNullIfExpression, validateObjectExpression, validateOnClause, validateOrderByClause, validateOrderByItem, validateOrExpression, validateRangeVariableDeclaration, validateResultVariable, validateSelectClause, validateSelectStatement, validateSimpleFromClause, validateSimpleSelectClause, validateSimpleSelectStatement, validateSizeExpression, validateSqrtExpression, validateStateFieldPathExpression, validateSubstringExpression, validateSubtractionExpression, validateSumFunction, validateTreatExpression, validateTrimExpression, validateTypeExpression, validateUpdateClause, validateUpdateItem, validateUpdateStatement, validateUpperExpression, validateValueExpression, validateWhenClause, validateWhereClause, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.AbstractValidator
addProblem, addProblem, addProblem, addProblem, buildChildrenCollector, buildNestedArrayVisitor, buildOwningStatementVisitor, buildProblem, buildSubqueryVisitor, getBypassChildCollectionExpressionVisitor, getBypassParentSubExpressionVisitor, getChildren, getChildrenCollectorVisitor, getExpressionRegistry, getExpressionValidator, getJPAVersion, getJPQLQueryBNFValidator, getJPQLQueryBNFValidator, getLiteralVisitor, getNestedArrayVisitor, getOwningClauseVisitor, getOwningStatementVisitor, getProvider, getProviderVersion, getQueryBNF, getSubqueryVisitor, isNestedArray, isSubquery, isValid, isValid, isValid, isValidWithChildCollectionBypass, isWithinSubquery, isWithinTopLevelQuery, length, literal, nestedArraySize, position, problemsSize, setProblems, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.persistence.jpa.jpql.parser.ExpressionVisitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
 

Constructor Detail

AbstractEclipseLinkSemanticValidator

protected AbstractEclipseLinkSemanticValidator(SemanticValidatorHelper helper,
                                               EclipseLinkSemanticValidatorExtension extension)
Creates a new AbstractEclipseLinkSemanticValidator.

Parameters:
helper - The given helper allows this validator to access the JPA artifacts without using Hermes SPI
extension - The following extension can be used to give access to non-JPA metadata artifacts, such as database tables and columns
Throws:
java.lang.NullPointerException - The given SemanticValidatorHelper cannot be null
Method Detail

buildLiteralVisitor

protected LiteralVisitor buildLiteralVisitor()
Creates the visitor that can retrieve some information about various literal.

Specified by:
buildLiteralVisitor in class AbstractValidator
Returns:
A new LiteralVisitor

buildOwningClauseVisitor

protected AbstractValidator.OwningClauseVisitor buildOwningClauseVisitor()
Creates the visitor that traverses the parent hierarchy of any Expression and stops at the first Expression that is a clause.

Specified by:
buildOwningClauseVisitor in class AbstractValidator
Returns:
A new AbstractValidator.OwningClauseVisitor

buildSubquerySelectItemCalculator

protected AbstractEclipseLinkSemanticValidator.SubquerySelectItemCalculator buildSubquerySelectItemCalculator()

buildTableExpressionVisitor

protected AbstractEclipseLinkSemanticValidator.TableExpressionVisitor buildTableExpressionVisitor()

buildTopLevelFirstDeclarationVisitor

protected AbstractEclipseLinkSemanticValidator.TopLevelFirstDeclarationVisitor buildTopLevelFirstDeclarationVisitor()

Overrides:
buildTopLevelFirstDeclarationVisitor in class AbstractSemanticValidator

getDeclaration

protected JPQLQueryDeclaration getDeclaration(java.lang.String variableName)

getExtension

protected EclipseLinkSemanticValidatorExtension getExtension()
Returns the extension that gives access to non-JPA metadata artifacts, such as database tables and columns.

Returns:
An extension giving access to non-JPA metadata artifacts or EclipseLinkSemanticValidatorExtension.NULL_EXTENSION if no extension was provided

getSubquerySelectItemCalculator

protected AbstractEclipseLinkSemanticValidator.SubquerySelectItemCalculator getSubquerySelectItemCalculator()

getTableExpressionVisitor

protected AbstractEclipseLinkSemanticValidator.TableExpressionVisitor getTableExpressionVisitor()

isTableExpression

protected boolean isTableExpression(Expression expression)

selectClausePathExpressionPathType

protected AbstractSemanticValidator.PathType selectClausePathExpressionPathType()
Returns the type of path expression that is allowed in the SELECT clause.

Specified by:
selectClausePathExpressionPathType in class AbstractSemanticValidator
Returns:
The type of path expressions allowed. The spec defines it as basic or object mapping only, i.e. collection-valued path expression is not allowed

subquerySelectItemCount

protected int subquerySelectItemCount(Expression subquery)
Retrieves the number of select items the given subquery has.

Parameters:
subquery - The Expression to visit, which should represents a subquery
Returns:
The number of select items or 0 if the subquery is malformed or incomplete

validateFunctionExpression

protected void validateFunctionExpression(FunctionExpression expression)
Validates the given FunctionExpression.

Overrides:
validateFunctionExpression in class AbstractSemanticValidator
Parameters:
expression - The FunctionExpression to validate

validateInExpression

protected void validateInExpression(InExpression expression)
Validates the given InExpression. The test to perform is:

Overrides:
validateInExpression in class AbstractSemanticValidator
Parameters:
expression - The InExpression to validate

validateRangeVariableDeclarationRootObject

protected void validateRangeVariableDeclarationRootObject(RangeVariableDeclaration expression)
Validates the "root" object of the given RangeVariableDeclaration.

Overrides:
validateRangeVariableDeclarationRootObject in class AbstractSemanticValidator
Parameters:
expression - The RangeVariableDeclaration that needs its "root" object to be validated

validPathExpressionTypeForInExpression

protected AbstractSemanticValidator.PathType validPathExpressionTypeForInExpression()
Returns the type of path expression that is valid for the expression being tested by an IN expression; which is the left expression.

Overrides:
validPathExpressionTypeForInExpression in class AbstractSemanticValidator
Returns:
By default, any field (without collection) is allowed

validateThirdPartyStateFieldPathExpression

protected java.lang.Boolean validateThirdPartyStateFieldPathExpression(StateFieldPathExpression expression)
Validates the given StateFieldPathExpression, which means the path does not represent a mapping, or an enum constant.

Overrides:
validateThirdPartyStateFieldPathExpression in class AbstractSemanticValidator
Parameters:
expression - The StateFieldPathExpression the validate
Returns:
Boolean.TRUE or Boolean.FALSE if the given StateFieldPathExpression was validated by this method; null if it could not be validated (as being valid or invalid)

validPathExpressionTypeForStringExpression

protected AbstractSemanticValidator.PathType validPathExpressionTypeForStringExpression()
Returns the type of path expression that is valid for a string expression; which is the left expression in a LIKE expression.

Overrides:
validPathExpressionTypeForStringExpression in class AbstractSemanticValidator
Returns:
By default, only basic field are allowed

visit

public void visit(AsOfClause expression)
Visits the AsOfClause expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The Expression to visit

visit

public void visit(CastExpression expression)
Visits the CastExpression expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The Expression to visit

visit

public void visit(ConnectByClause expression)
Visits the ConnectByClause expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The ConnectByClause to visit

visit

public void visit(DatabaseType expression)
Visits the DatabaseType expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The DatabaseType to visit

visit

public void visit(ExtractExpression expression)
Visits the ExtractExpression expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The Expression to visit

visit

public void visit(HierarchicalQueryClause expression)
Visits the HierarchicalQueryClause expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The HierarchicalQueryClause to visit

visit

public void visit(OrderSiblingsByClause expression)
Visits the OrderSiblingsByClause expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The Expression to visit

visit

public void visit(RegexpExpression expression)
Visits the RegexpExpression expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The Expression to visit

visit

public void visit(StartWithClause expression)
Visits the StartWithClause expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The StartWithClause to visit

visit

public void visit(TableExpression expression)
Visits the TableExpression expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The Expression to visit

visit

public void visit(TableVariableDeclaration expression)
Visits the TableVariableDeclaration expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The Expression to visit

visit

public void visit(UnionClause expression)
Visits the UnionClause expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The Expression to visit

EclipseLink 2.5.0, build 'v20130507-3faac2b' API Reference