/** * {@inheritDoc} */ public void visit(StateFieldPathExpression expression) { // If the path ends with '.', then the path is incomplete // so we can't resolve the type if (!expression.endsWithDot()) { // Check first to see if it's an enum type String path = expression.toActualText(); IType type = queryContext.getTypeRepository().getEnumType(path); if (type != null) { resolver = buildEnumResolver(expression, type, path); } else { expression.getIdentificationVariable().accept(this); for (int index = expression.hasVirtualIdentificationVariable() ? 0 : 1, count = expression.pathSize(); index < count; index++) { path = expression.getPath(index); resolver = buildStateFieldResolver(expression.getPath(index)); } } } else { resolver = buildNullResolver(); } }
/** * 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) { try { PathResolver resolver = new PathResolver(); resolver.length = expression.pathSize(); resolver.checkMappingType = true; expression.accept(resolver); return resolver.localExpression; } finally { this.type[0] = null; this.queryExpression = null; } }
/** * Creates the {@link AbstractExpression} to represent the given word. * * @param word The word that was parsed * @return The encapsulated {@link AbstractExpression} */ protected AbstractExpression buildEncapsulatedExpression(WordParser wordParser, String word) { return new StateFieldPathExpression(this, word); }
/** * {@inheritDoc} */ @Override public void visit(StateFieldPathExpression expression) { // A fully qualified enum constant is parsed as a state field path expression if (!expression.startsWithDot()) { visit(expression, expression.toActualText(), 0); } } }
if (expression.hasIdentificationVariable()) { expression.getIdentificationVariable().accept(this); if (!expression.endsWithDot()) { addProblem(expression, StateFieldPathExpression_CollectionType, expression.toActualText()); valid = false; addProblem(expression, StateFieldPathExpression_NoMapping, expression.toParsedText()); valid = false; addProblem(expression, StateFieldPathExpression_AssociationField, expression.toActualText()); valid = false; addProblem(expression, StateFieldPathExpression_BasicField, expression.toActualText()); valid = false; Object type = helper.getType(expression.toParsedText(0, expression.pathSize() - 1)); String enumConstant = expression.getPath(expression.pathSize() - 1); boolean found = false; usedIdentificationVariables.remove(expression.getIdentificationVariable()); addProblem(expression, StateFieldPathExpression_NotResolvable, expression.toActualText()); valid = false; addProblem(expression, StateFieldPathExpression_NoMapping, expression.toActualText()); valid = false;
(pathExpression.hasIdentificationVariable() || pathExpression.hasVirtualIdentificationVariable())) { Object managedType = helper.getManagedType(pathExpression.getIdentificationVariable()); for (int index = pathExpression.hasVirtualIdentificationVariable() ? 0 : 1, count = pathExpression.pathSize(); index < count; index++) { String path = pathExpression.getPath(index); Object mapping = helper.getMappingNamed(managedType, path); addProblem(pathExpression, UpdateItem_NotResolvable, pathExpression.toParsedText()); valid = false; break; addProblem(pathExpression, UpdateItem_NotResolvable, pathExpression.toParsedText()); valid = false; break; addProblem(pathExpression, UpdateItem_NotResolvable, pathExpression.toParsedText()); valid = false;
/** * {@inheritDoc} */ @Override public void visit(StateFieldPathExpression expression) { // Temporarily change the null allowed flag if the state field is a foreign reference mapping Expression queryExpression = queryContext.buildModifiedPathExpression(expression); // Register the EclipseLink Expression with the state field name String name = expression.getPath(expression.pathSize() - 1); addAttribute(name, queryExpression); query.dontRetrievePrimaryKeys(); }
String variableName = literal(expression.getIdentificationVariable(), LiteralType.IDENTIFICATION_VARIABLE); String columnName = expression.getPath(1);
/** * {@link InputParameter} */ @Override public void visit(IdentificationVariable expression) { // Check to see if the identification variable is "virtual" and internally // changed to a state field path expression. If so, it means it's an unqualified // path found in an UPDATE or DELETE query StateFieldPathExpression pathExpression = expression.isVirtual() ? expression.getStateFieldPathExpression() : null; if (pathExpression != null) { pathExpression.accept(this); } else { Declaration declaration = queryContext.findDeclaration(expression.getVariableName()); // A null declaration Expression would mean it's the first package of an enum type if (declaration != null) { descriptor = declaration.getDescriptor(); } } }
/** * Populate filter clause. * * @param conditionalExpression * the conditional expression * @return the filter clause */ private FilterClause populateFilterClause(ComparisonExpression conditionalExpression) { String property = ((StateFieldPathExpression) conditionalExpression.getLeftExpression()).getPath(1); String condition = conditionalExpression.getComparisonOperator(); Expression rightExpression = conditionalExpression.getRightExpression(); Object value = (rightExpression instanceof InputParameter) ? kunderaQuery.getParametersMap().get( (rightExpression).toParsedText()) : rightExpression.toParsedText(); return (condition != null && property != null) ? kunderaQuery.new FilterClause(property, condition, value, property) : null; }
/** * Sets a virtual identification variable because the abstract schema name was parsed without * one. This is valid in an <b>UPDATE</b> and <b>DELETE</b> queries. This internally transforms * the what was thought to be an identification variable to a path expression. * * @param variableName The identification variable that was generated to identify the "root" object */ public void setVirtualIdentificationVariable(String variableName) { virtual = true; stateFieldPathExpression = new StateFieldPathExpression(getParent(), getText()); stateFieldPathExpression.setVirtualIdentificationVariable(variableName); rebuildActualText(); rebuildParsedText(); }
String columnName = getColumnName(metadata, entityType, sfpExp.toActualText()); String actualColumnName = columnName; if (hasLob) String columnName = getColumnName(metadata, entityType, sfpExp.toActualText()); String actualColumnName = columnName; if (hasLob)
/** * {@inheritDoc} */ @Override public void visit(StateFieldPathExpression expression) { visitPathExpression(expression, false, expression.pathSize()); }
/** * {@inheritDoc} */ @Override public void visit(StateFieldPathExpression expression) { this.expression = new CollectionValuedPathExpression(parent, expression.getText()); } }
/** * {@inheritDoc} */ public JPQLQueryBNF getQueryBNF() { return getQueryBNF(StateFieldPathExpressionBNF.ID); } }
if (expression.endsWithDot()) { appendable = false;
if (expression.hasIdentificationVariable()) { expression.getIdentificationVariable().accept(this); if (!expression.endsWithDot()) { addProblem(expression, StateFieldPathExpression_CollectionType, expression.toActualText()); valid = false; addProblem(expression, StateFieldPathExpression_NoMapping, expression.toParsedText()); valid = false; addProblem(expression, StateFieldPathExpression_AssociationField, expression.toActualText()); valid = false; addProblem(expression, StateFieldPathExpression_BasicField, expression.toActualText()); valid = false; Object type = helper.getType(expression.toParsedText(0, expression.pathSize() - 1)); String enumConstant = expression.getPath(expression.pathSize() - 1); boolean found = false; usedIdentificationVariables.remove(expression.getIdentificationVariable()); addProblem(expression, StateFieldPathExpression_NotResolvable, expression.toActualText()); valid = false; addProblem(expression, StateFieldPathExpression_NoMapping, expression.toActualText()); valid = false;
(pathExpression.hasIdentificationVariable() || pathExpression.hasVirtualIdentificationVariable())) { Object managedType = helper.getManagedType(pathExpression.getIdentificationVariable()); for (int index = pathExpression.hasVirtualIdentificationVariable() ? 0 : 1, count = pathExpression.pathSize(); index < count; index++) { String path = pathExpression.getPath(index); Object mapping = helper.getMappingNamed(managedType, path); addProblem(pathExpression, UpdateItem_NotResolvable, pathExpression.toParsedText()); valid = false; break; addProblem(pathExpression, UpdateItem_NotResolvable, pathExpression.toParsedText()); valid = false; break; addProblem(pathExpression, UpdateItem_NotResolvable, pathExpression.toParsedText()); valid = false;
/** * {@inheritDoc} */ @Override public void visit(StateFieldPathExpression expression) { // Temporarily change the null allowed flag if the state field is a foreign reference mapping Expression queryExpression = queryContext.buildModifiedPathExpression(expression); // Register the EclipseLink Expression with the state field name String name = expression.getPath(expression.pathSize() - 1); addAttribute(name, queryExpression); query.dontRetrievePrimaryKeys(); }
String variableName = literal(expression.getIdentificationVariable(), LiteralType.IDENTIFICATION_VARIABLE); String columnName = expression.getPath(1);