Class AbstractEclipseLinkSemanticValidator
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.parser.AnonymousExpressionVisitor
-
- org.eclipse.persistence.jpa.jpql.AbstractValidator
-
- org.eclipse.persistence.jpa.jpql.AbstractSemanticValidator
-
- 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.1
- See Also:
EclipseLinkGrammarValidator
- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractEclipseLinkSemanticValidator.EclipseLinkOwningClauseVisitor
This visitor retrieves the clause owning the visitedExpression
.protected static class
AbstractEclipseLinkSemanticValidator.SubquerySelectItemCalculator
protected static class
AbstractEclipseLinkSemanticValidator.TableExpressionVisitor
protected static class
AbstractEclipseLinkSemanticValidator.TopLevelFirstDeclarationVisitor
-
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
Constructors Modifier Constructor Description protected
AbstractEclipseLinkSemanticValidator(SemanticValidatorHelper helper, EclipseLinkSemanticValidatorExtension extension)
Creates a newAbstractEclipseLinkSemanticValidator
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 anyExpression
and stops at the firstExpression
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 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
validateRangeVariableDeclarationRootObject(RangeVariableDeclaration expression)
Validates the "root" object of the givenRangeVariableDeclaration
.protected java.lang.Boolean
validateThirdPartyStateFieldPathExpression(StateFieldPathExpression expression)
Validates the givenStateFieldPathExpression
, which means the path does not represent a mapping, or an enum constant.protected AbstractSemanticValidator.PathType
validPathExpressionTypeForCountFunction()
Returns the type of path expression that is valid for a count function; which is the left expression in aCOUNT
expression.protected AbstractSemanticValidator.PathType
validPathExpressionTypeForInExpression()
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
validPathExpressionTypeForInItem()
Returns the type of path expression that is valid for anIN
items; which is the left expression in aIN
expression.protected AbstractSemanticValidator.PathType
validPathExpressionTypeForStringExpression()
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 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 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:
java.lang.NullPointerException
- The givenSemanticValidatorHelper
cannot benull
-
-
Method Detail
-
buildLiteralVisitor
protected LiteralVisitor buildLiteralVisitor()
Creates the visitor that can retrieve some information about various literal.- Specified by:
buildLiteralVisitor
in classAbstractValidator
- Returns:
- A new
LiteralVisitor
-
buildOwningClauseVisitor
protected AbstractValidator.OwningClauseVisitor buildOwningClauseVisitor()
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
protected AbstractEclipseLinkSemanticValidator.TableExpressionVisitor buildTableExpressionVisitor()
-
buildTopLevelFirstDeclarationVisitor
protected AbstractEclipseLinkSemanticValidator.TopLevelFirstDeclarationVisitor buildTopLevelFirstDeclarationVisitor()
- Overrides:
buildTopLevelFirstDeclarationVisitor
in classAbstractSemanticValidator
-
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 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
protected int subquerySelectItemCount(Expression subquery)
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
protected void validateFunctionExpression(FunctionExpression expression)
Validates the givenFunctionExpression
.- Overrides:
validateFunctionExpression
in classAbstractSemanticValidator
- Parameters:
expression
- TheFunctionExpression
to validate
-
validateInExpression
protected void validateInExpression(InExpression expression)
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
protected void validateRangeVariableDeclarationRootObject(RangeVariableDeclaration expression)
Validates the "root" object of the givenRangeVariableDeclaration
.- Overrides:
validateRangeVariableDeclarationRootObject
in classAbstractSemanticValidator
- Parameters:
expression
- TheRangeVariableDeclaration
that needs its "root" object to be validated
-
validPathExpressionTypeForCountFunction
protected AbstractSemanticValidator.PathType validPathExpressionTypeForCountFunction()
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
protected AbstractSemanticValidator.PathType validPathExpressionTypeForInExpression()
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
protected AbstractSemanticValidator.PathType validPathExpressionTypeForInItem()
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
protected java.lang.Boolean validateThirdPartyStateFieldPathExpression(StateFieldPathExpression expression)
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
protected AbstractSemanticValidator.PathType validPathExpressionTypeForStringExpression()
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
public void visit(AsOfClause expression)
Visits theAsOfClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
public void visit(CastExpression expression)
Visits theCastExpression
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
public void visit(ConnectByClause expression)
Visits theConnectByClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheConnectByClause
to visit
-
visit
public void visit(DatabaseType expression)
Visits theDatabaseType
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheDatabaseType
to visit
-
visit
public void visit(ExtractExpression expression)
Visits theExtractExpression
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
public void visit(HierarchicalQueryClause expression)
Visits theHierarchicalQueryClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheHierarchicalQueryClause
to visit
-
visit
public void visit(OrderSiblingsByClause expression)
Visits theOrderSiblingsByClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
public void visit(RegexpExpression expression)
Visits theRegexpExpression
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
public void visit(StartWithClause expression)
Visits theStartWithClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheStartWithClause
to visit
-
visit
public void visit(TableExpression expression)
Visits theTableExpression
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
public void visit(TableVariableDeclaration expression)
Visits theTableVariableDeclaration
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
visit
public void visit(UnionClause expression)
Visits theUnionClause
expression.- Specified by:
visit
in interfaceEclipseLinkExpressionVisitor
- Parameters:
expression
- TheExpression
to visit
-
-