/** * Returns the root {@link Expression} for which all new {@link Expression expressions} a child. * * @return The root {@link Expression} of the query or subquery */ Expression getBaseExpression() { // Retrieve the first declaration, which is the base declaration (For top-level query, it's // always a range over an abstract schema name. For subqueries, it's either a range over an // abstract schema name or a derived path expression) return getDeclarationResolver().getFirstDeclaration().getQueryExpression(); }
/** * {@inheritDoc} */ @Override public void visit(KeywordExpression expression) { Expression queryExpression = queryContext.buildExpression(expression, type); addAttribute("CONSTANT", queryExpression); }
/** * Creates a new EclipseLink {@link Expression} by visiting the given JPQL {@link * CollectionValuedPathExpression} that is used in the <code><b>GROUP BY</b></code> clause. * * @param expression The {@link CollectionValuedPathExpression} to convert into an EclipseLink * {@link Expression} * @return The EclipseLink {@link Expression} representation of that path expression */ Expression buildGroupByExpression(CollectionValuedPathExpression expression) { return expressionBuilder().buildGroupByExpression(expression); }
/** * Returns the type of the given {@link QueryKey}, which is the persistent field type. * * @param queryKey The {@link QueryKey} to retrieve its persistent field type * @return The persistent field type */ Class<?> calculateQueryKeyType(QueryKey queryKey) { return typeResolver().calculateQueryKeyType(queryKey); }
/** * Determines whether the given identification variable is defining a join or a collection member * declaration expressions. * * @param variableName The identification variable to check for what it maps * @return <code>true</code> if the given identification variable maps a collection-valued field * defined in a <code>JOIN</code> or <code>IN</code> expression; <code>false</code> if it's not * defined or it's mapping an abstract schema name */ boolean isCollectionIdentificationVariable(String variableName) { return getDeclarationResolver().isCollectionIdentificationVariable(variableName); }
/** * Determines whether the given variable name is an identification variable name used to define * an abstract schema name. * * @param variableName The name of the variable to verify if it's defined in a range variable * declaration in the current query or any parent query * @return <code>true</code> if the variable name is mapping an abstract schema name; <code>false</code> * if it's defined in a collection member declaration */ boolean isRangeIdentificationVariable(String variableName) { return getDeclarationResolverImp().isRangeIdentificationVariable(variableName); }
/** * Resolves the given {@link org.eclipse.persistence.jpa.jpql.parser.Expression Expression} and * returns the {@link DatabaseMapping}. * * @param expression The {@link org.eclipse.persistence.jpa.jpql.parser.Expression Expression} to * resolve by traversing its path expression * @return The {@link DatabaseMapping} that is representing the last path or <code>null</code> if * the path expression could not be resolved */ DatabaseMapping resolveMapping(org.eclipse.persistence.jpa.jpql.parser.Expression expression) { return typeResolver().resolveMapping(expression); }
/** * Resolves the given {@link org.eclipse.persistence.jpa.jpql.parser.Expression Expression} and * either returns the {@link DatabaseMapping} or the {@link QueryKey} object. * * @param expression The {@link org.eclipse.persistence.jpa.jpql.parser.Expression Expression} to * resolve by traversing its path expression * @return Either the {@link DatabaseMapping} or the {@link QueryKey} that is representing the * last path or <code>null</code> if the path expression could not be resolved */ Object resolveMappingObject(org.eclipse.persistence.jpa.jpql.parser.Expression expression) { return typeResolver().resolveMappingObject(expression); }
/** * Converts the given {@link org.eclipse.persistence.jpa.jpql.parser.Expression JPQL Expression} * into an {@link Expression}. * * @param expression The {@link org.eclipse.persistence.jpa.jpql.parser.Expression JPQL Expression} * to visit and to convert into an {@link Expression} * @return The {@link Expression} representing the given parsed expression */ Expression buildExpression(org.eclipse.persistence.jpa.jpql.parser.Expression expression) { return expressionBuilder().buildExpression(expression, EMPTY_TYPE); }
/** * Creates a new EclipseLink {@link Expression} by visiting the given JPQL {@link * StateFieldPathExpression}. This method temporarily changes the null allowed flag if the state * field is a foreign reference mapping * * @param expression The {@link StateFieldPathExpression} to convert into an EclipseLink {@link * Expression} * @return The EclipseLink {@link Expression} representation of that path expression */ Expression buildModifiedPathExpression(StateFieldPathExpression expression) { return expressionBuilder().buildModifiedPathExpression(expression); }
/** * Returns the type of the given {@link DatabaseMapping}, which is the persistent field type. * * @param mapping The {@link DatabaseMapping} to retrieve its persistent field type * @return The persistent field type */ Class<?> calculateMappingType(DatabaseMapping mapping) { return typeResolver().calculateMappingType(mapping); }
/** * Returns the Java class of the given {@link Expression}. * * @param expression The {@link Expression} for which its type will be calculated * @return Either the Java class that was resolved or the <code>null</code> if it could not be resolved */ Class<?> getType(org.eclipse.persistence.jpa.jpql.parser.Expression expression) { return typeResolver().resolve(expression); }
TypeResolver typeResolver() { if (parent != null) { return parent.typeResolver(); } if (typeResolver == null) { typeResolver = new TypeResolver(this); } return typeResolver; } }
/** * {@inheritDoc} */ @Override public void visit(LengthExpression expression) { Expression queryExpression = queryContext.buildExpression(expression, type); addAttribute(ExpressionTools.EMPTY_STRING, queryExpression, type[0]); }
/** * {@inheritDoc} */ @Override public void visit(ModExpression expression) { Expression queryExpression = queryContext.buildExpression(expression, type); addAttribute(ExpressionTools.EMPTY_STRING, queryExpression, type[0]); }
/** * {@inheritDoc} */ @Override public void visit(AbsExpression expression) { Expression queryExpression = queryContext.buildExpression(expression, type); addAttribute(ExpressionTools.EMPTY_STRING, queryExpression, type[0]); }
/** * {@inheritDoc} */ @Override public void visit(ConcatExpression expression) { Expression queryExpression = queryContext.buildExpression(expression, type); addAttribute(ExpressionTools.EMPTY_STRING, queryExpression, type[0]); }
/** * {@inheritDoc} */ @Override public void visit(EntryExpression expression) { Expression queryExpression = queryContext.buildExpression(expression, type); addAttribute(" MapEntry", queryExpression); }
/** * {@inheritDoc} */ @Override public void visit(LocateExpression expression) { Expression queryExpression = queryContext.buildExpression(expression, type); addAttribute(ExpressionTools.EMPTY_STRING, queryExpression, type[0]); }
/** * {@inheritDoc} */ @Override public void visit(NullIfExpression expression) { Expression queryExpression = queryContext.buildExpression(expression, type); addAttribute(NullIfExpression.NULLIF, queryExpression); }