Class AbstractEclipseLinkSemanticValidator
- All Implemented Interfaces:
EclipseLinkExpressionVisitor
,ExpressionVisitor
- Direct Known Subclasses:
EclipseLinkSemanticValidator
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.
- Since:
- 2.4
- Version:
- 2.5.1
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
This visitor retrieves the clause owning the visitedExpression
.protected static final class
protected static final class
protected static final class
Nested classes/interfaces inherited from class org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
AbstractSemanticValidator.CollectionValuedPathExpressionVisitor, AbstractSemanticValidator.ComparingEntityTypeLiteralVisitor, AbstractSemanticValidator.ComparisonExpressionVisitor, AbstractSemanticValidator.FirstDeclarationVisitor, AbstractSemanticValidator.InItemsVisitor, 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
ModifierConstructorDescriptionprotected
AbstractEclipseLinkSemanticValidator
(SemanticValidatorHelper helper, EclipseLinkSemanticValidatorExtension extension) Creates a newAbstractEclipseLinkSemanticValidator
. -
Method Summary
Modifier and TypeMethodDescriptionprotected LiteralVisitor
Creates the visitor that can retrieve some information about various literal.protected AbstractValidator.OwningClauseVisitor
Creates the visitor that traverses the parent hierarchy of anyExpression
and stops at the firstExpression
that is a clause.protected JPQLQueryDeclaration
getDeclaration
(String variableName) protected EclipseLinkSemanticValidatorExtension
Returns the extension that gives access to non-JPA metadata artifacts, such as database tables and columns.protected boolean
isTableExpression
(Expression expression) protected AbstractSemanticValidator.PathType
Returns the type of path expression that is allowed in theSELECT
clause.protected int
subquerySelectItemCount
(Expression subquery) Retrieves the number of select items the given subquery has.protected void
validateFunctionExpression
(FunctionExpression expression) Validates the givenFunctionExpression
.protected void
validateInExpression
(InExpression expression) Validates the givenInExpression
.protected void
Validates the "root" object of the givenRangeVariableDeclaration
.protected Boolean
Validates the givenStateFieldPathExpression
, which means the path does not represent a mapping, or an enum constant.protected AbstractSemanticValidator.PathType
Returns the type of path expression that is valid for a count function; which is the left expression in aCOUNT
expression.protected AbstractSemanticValidator.PathType
Returns the type of path expression that is valid for the expression being tested by anIN
expression; which is the left expression.protected AbstractSemanticValidator.PathType
Returns the type of path expression that is valid for anIN
items; which is the left expression in aIN
expression.protected AbstractSemanticValidator.PathType
Returns the type of path expression that is valid for a string expression; which is the left expression in aLIKE
expression.void
visit
(AsOfClause expression) Visits theAsOfClause
expression.void
visit
(CastExpression expression) Visits theCastExpression
expression.void
visit
(ConnectByClause expression) Visits theConnectByClause
expression.void
visit
(DatabaseType expression) Visits theDatabaseType
expression.void
visit
(ExtractExpression expression) Visits theExtractExpression
expression.void
visit
(HierarchicalQueryClause expression) Visits theHierarchicalQueryClause
expression.void
visit
(OrderSiblingsByClause expression) Visits theOrderSiblingsByClause
expression.void
visit
(RegexpExpression expression) Visits theRegexpExpression
expression.void
visit
(StartWithClause expression) Visits theStartWithClause
expression.void
visit
(TableExpression expression) Visits theTableExpression
expression.void
visit
(TableVariableDeclaration expression) Visits theTableVariableDeclaration
expression.void
visit
(UnionClause expression) Visits theUnionClause
expression.Methods inherited from class org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
buildComparingEntityTypeLiteralVisitor, buildInItemsVisitor, buildSubqueryFirstDeclarationVisitor, dispose, findVirtualIdentificationVariable, getCollectionValuedPathExpression, getCollectionValuedPathExpressionVisitor, getComparingEntityTypeLiteralVisitor, getComparisonExpressionVisitor, getGrammar, getInItemsVisitor, 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, validateJoinCollectionValuedPathExpression, 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 org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor
visit, visit, visit, visit, visit, visit, visit, visit, 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, visit, visit, visit, visit, visit, visit, visit, visit, visit
-
Constructor Details
-
AbstractEclipseLinkSemanticValidator
protected AbstractEclipseLinkSemanticValidator(SemanticValidatorHelper helper, EclipseLinkSemanticValidatorExtension extension) Creates a newAbstractEclipseLinkSemanticValidator
.- Parameters:
helper
- The given helper allows this validator to access the JPA artifacts without using Hermes SPIextension
- The following extension can be used to give access to non-JPA metadata artifacts, such as database tables and columns- Throws:
NullPointerException
- The givenSemanticValidatorHelper
cannot benull
-
-
Method Details
-
buildLiteralVisitor
Description copied from class:AbstractValidator
Creates the visitor that can retrieve some information about various literal.- Specified by:
buildLiteralVisitor
in classAbstractValidator
- Returns:
- A new
LiteralVisitor
-
buildOwningClauseVisitor
Description copied from class:AbstractValidator
Creates the visitor that traverses the parent hierarchy of anyExpression
and stops at the firstExpression
that is a clause.- Specified by:
buildOwningClauseVisitor
in classAbstractValidator
- Returns:
- A new
AbstractValidator.OwningClauseVisitor
-
buildSubquerySelectItemCalculator
protected AbstractEclipseLinkSemanticValidator.SubquerySelectItemCalculator buildSubquerySelectItemCalculator() -
buildTableExpressionVisitor
-
buildTopLevelFirstDeclarationVisitor
protected AbstractEclipseLinkSemanticValidator.TopLevelFirstDeclarationVisitor buildTopLevelFirstDeclarationVisitor()- Overrides:
buildTopLevelFirstDeclarationVisitor
in classAbstractSemanticValidator
-
getDeclaration
-
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
-
isTableExpression
-
selectClausePathExpressionPathType
Description copied from class:AbstractSemanticValidator
Returns the type of path expression that is allowed in theSELECT
clause.- Specified by:
selectClausePathExpressionPathType
in classAbstractSemanticValidator
- 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
Retrieves the number of select items the given subquery has.- Parameters:
subquery
- TheExpression
to visit, which should represents a subquery- Returns:
- The number of select items or 0 if the subquery is malformed or incomplete
-
validateFunctionExpression
Description copied from class:AbstractSemanticValidator
Validates the givenFunctionExpression
.- Overrides:
validateFunctionExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheFunctionExpression
to validate
-
validateInExpression
Description copied from class:AbstractSemanticValidator
Validates the givenInExpression
. The test to perform is:- If the expression is a path expression, validation makes sure it is an association mapping, a basic field is not allowed.
- Overrides:
validateInExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheInExpression
to validate
-
validateRangeVariableDeclarationRootObject
Description copied from class:AbstractSemanticValidator
Validates the "root" object of the givenRangeVariableDeclaration
.- Overrides:
validateRangeVariableDeclarationRootObject
in classAbstractSemanticValidator
- Parameters:
expression
- TheRangeVariableDeclaration
that needs its "root" object to be validated
-
validPathExpressionTypeForCountFunction
Description copied from class:AbstractSemanticValidator
Returns the type of path expression that is valid for a count function; which is the left expression in aCOUNT
expression.- Overrides:
validPathExpressionTypeForCountFunction
in classAbstractSemanticValidator
- Returns:
- By default, any field are allowed except collection
-
validPathExpressionTypeForInExpression
Description copied from class:AbstractSemanticValidator
Returns the type of path expression that is valid for the expression being tested by anIN
expression; which is the left expression.- Overrides:
validPathExpressionTypeForInExpression
in classAbstractSemanticValidator
- Returns:
- By default, any field (without collection) is allowed
-
validPathExpressionTypeForInItem
Description copied from class:AbstractSemanticValidator
Returns the type of path expression that is valid for anIN
items; which is the left expression in aIN
expression.- Overrides:
validPathExpressionTypeForInItem
in classAbstractSemanticValidator
- Returns:
- By default, any field are allowed except collection
-
validateThirdPartyStateFieldPathExpression
Description copied from class:AbstractSemanticValidator
Validates the givenStateFieldPathExpression
, which means the path does not represent a mapping, or an enum constant.- Overrides:
validateThirdPartyStateFieldPathExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheStateFieldPathExpression
the validate- Returns:
Boolean.TRUE
orBoolean.FALSE
if the givenStateFieldPathExpression
was validated by this method;null
if it could not be validated (as being valid or invalid)
-
validPathExpressionTypeForStringExpression
Description copied from class:AbstractSemanticValidator
Returns the type of path expression that is valid for a string expression; which is the left expression in aLIKE
expression.- Overrides:
validPathExpressionTypeForStringExpression
in classAbstractSemanticValidator
- Returns:
- By default, only basic field are allowed
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theAsOfClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theCastExpression
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theConnectByClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheConnectByClause
to visit
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theDatabaseType
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheDatabaseType
to visit
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theExtractExpression
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theHierarchicalQueryClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheHierarchicalQueryClause
to visit
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theOrderSiblingsByClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theRegexpExpression
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theStartWithClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheStartWithClause
to visit
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theTableExpression
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theTableVariableDeclaration
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
Description copied from interface:EclipseLinkExpressionVisitor
Visits theUnionClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-