EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jpa.jpql
Class EclipseLinkSemanticValidator

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.EclipseLinkSemanticValidator
All Implemented Interfaces:
EclipseLinkExpressionVisitor, ExpressionVisitor

public class EclipseLinkSemanticValidator
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.4.2
See Also:
EclipseLinkGrammarValidator
Author:
Pascal Filion
Since:
2.4

Nested Class Summary
protected  class EclipseLinkSemanticValidator.TopLevelFirstDeclarationVisitor
           
 
Nested classes/interfaces inherited from class org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
AbstractSemanticValidator.ComparingEntityTypeLiteralVisitor, AbstractSemanticValidator.ComparisonExpressionVisitor, AbstractSemanticValidator.FirstDeclarationVisitor, AbstractSemanticValidator.PathType, AbstractSemanticValidator.SubqueryFirstDeclarationVisitor
 
Nested classes/interfaces inherited from class org.eclipse.persistence.jpa.jpql.AbstractValidator
AbstractValidator.BypassChildCollectionExpressionVisitor, AbstractValidator.BypassParentSubExpressionVisitor, AbstractValidator.ChildrenCollectorVisitor, AbstractValidator.JPQLQueryBNFValidator, 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
EclipseLinkSemanticValidator(JPQLQueryContext queryContext)
          Creates a new EclipseLinkSemanticValidator.
EclipseLinkSemanticValidator(SemanticValidatorHelper helper)
          Creates a new EclipseLinkSemanticValidator.
 
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  EclipseLinkSemanticValidator.TopLevelFirstDeclarationVisitor buildTopLevelFirstDeclarationVisitor()
          
protected  boolean isEclipseLink2_4OrLater()
           
protected  AbstractSemanticValidator.PathType selectClausePathExpressionPathType()
          Returns the type of path expression that is allowed in the SELECT clause.
protected  void validateRangeVariableDeclarationRootObject(RangeVariableDeclaration expression)
          Validates the "root" object of the given RangeVariableDeclaration.
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(CastExpression expression)
          Visits the CastExpression expression.
 void visit(DatabaseType expression)
          Visits the DatabaseType expression.
 void visit(ExtractExpression expression)
          Visits the ExtractExpression expression.
 void visit(RegexpExpression 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, validateInExpression, 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
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.AbstractValidator
addProblem, addProblem, addProblem, addProblem, buildChildrenCollector, buildOwningStatementVisitor, buildProblem, buildSubqueryVisitor, getBypassChildCollectionExpressionVisitor, getBypassParentSubExpressionVisitor, getChildren, getChildrenCollectorVisitor, getExpressionRegistry, getExpressionValidator, getJPAVersion, getJPQLQueryBNFValidator, getJPQLQueryBNFValidator, getLiteralVisitor, getOwningClauseVisitor, getOwningStatementVisitor, getProviderVersion, getQueryBNF, getSubqueryVisitor, isSubquery, isValid, isValid, isValid, isValidWithChildCollectionBypass, isWithinSubquery, isWithinTopLevelQuery, length, literal, position, problemsSize, setProblems, visit
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor
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

EclipseLinkSemanticValidator

public EclipseLinkSemanticValidator(JPQLQueryContext queryContext)
Creates a new EclipseLinkSemanticValidator.

Parameters:
queryContext - The context used to query information about the JPQL query
Throws:
java.lang.NullPointerException - The given JPQLQueryContext cannot be null

EclipseLinkSemanticValidator

public EclipseLinkSemanticValidator(SemanticValidatorHelper helper)
Creates a new EclipseLinkSemanticValidator.

Parameters:
helper - The given helper allows this validator to access the JPA artifacts without using Hermes SPI
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

buildTopLevelFirstDeclarationVisitor

protected EclipseLinkSemanticValidator.TopLevelFirstDeclarationVisitor buildTopLevelFirstDeclarationVisitor()

Overrides:
buildTopLevelFirstDeclarationVisitor in class AbstractSemanticValidator

isEclipseLink2_4OrLater

protected boolean isEclipseLink2_4OrLater()

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

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

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(CastExpression expression)
Visits the CastExpression expression.

Specified by:
visit in interface EclipseLinkExpressionVisitor
Parameters:
expression - The Expression 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(RegexpExpression expression)

Specified by:
visit in interface EclipseLinkExpressionVisitor

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.4.2, build 'v20130514-5956486' API Reference