private void addUpdateClause(ListIterator<Expression> childUpdateClauseIter) { String columnTuple = childUpdateClauseIter.next().toActualText().trim(); String value = childUpdateClauseIter.next().toActualText().trim(); StringTokenizer tokenizer = new StringTokenizer(columnTuple, "."); columnTuple = getTokenizedValue(tokenizer); query.addUpdateClause(columnTuple, value); }
String left = ((ComparisonExpression) whereExp).getLeftExpression().toActualText(); String right = ((ComparisonExpression) whereExp).getRightExpression().toActualText(); if (right.startsWith(POSITIONAL_PREFIX) || right.startsWith(PARAMETERIZED_PREFIX)) ListIterator<Expression> inIter = ((InExpression) whereExp).getInItems().children().iterator(); Attribute attribute = entityType.getAttribute(((InExpression) whereExp).getExpression().toActualText() .split(DOT_REGEX)[1]); addInPredicateToBuilder(scannerBuilder, inIter, attribute);
/** * Check input parameter. * * @param expression * the expression * @return the string */ private String checkInputParameter(Expression expression) { return (expression instanceof InputParameter) ? kunderaQuery.getParametersMap() .get((expression).toParsedText()).toString() : expression.toParsedText().toString(); }
ListIterator<Expression> iterator = orderByItems.children().iterator(); while (iterator.hasNext())
/** * {@inheritDoc} */ @Override public void visit(org.eclipse.persistence.jpa.jpql.parser.Expression expression) { expression.accept(ExpressionBuilderVisitor.this); }
/** * {@inheritDoc} */ @Override public void visit(CoalesceExpression expression) { List<Expression> expressions = new ArrayList<Expression>(); List<Class<?>> types = new LinkedList<Class<?>>(); // Create the Expression for each scalar expression for (org.eclipse.persistence.jpa.jpql.parser.Expression child : expression.getExpression().children()) { child.accept(this); expressions.add(queryExpression); types.add(type[0]); // Set the type on an untyped ParameterExpression, so that // valid types can be passed for null parameter values in JDBC if (queryExpression.isParameterExpression()) { ParameterExpression paramExpression = (ParameterExpression) queryExpression; if (paramExpression.getType() == null || paramExpression.getType().equals(Object.class)) { paramExpression.setType(type[0]); } } } // Create the COALESCE expression queryExpression = queryContext.getBaseExpression(); queryExpression = queryExpression.coalesce(expressions); // Set the expression type type[0] = queryContext.typeResolver().compareCollectionEquivalentTypes(types); }
/** * Returns the length of the string representation of the given {@link Expression}. * * @param expression The {@link Expression} to retrieve the length of its string * @return The length of the string representation of the given {@link Expression} */ protected int length(Expression expression) { return expression.getLength(); }
/** * Calculates the position of the given {@link Expression} by calculating the length of what is before. * * @param expression The {@link Expression} for which its position within the parsed tree needs * to be determined * @param length The current cursor position within the JPQL query while digging into the tree * until the search reaches the expression * @return The length of the string representation for what is coming before the given {@link Expression} * @since 2.4 */ protected final int calculatePosition(Expression expression, int length) { Expression parent = expression.getParent(); // Reach the root if (parent == null) { return length; } // Traverse the child expression until the expression for (Expression childExpression : parent.orderedChildren()) { // Continue to calculate the position by going up the hierarchy if (childExpression == expression) { return calculatePosition(parent, length); } length += childExpression.getLength(); } // It should never reach this throw new RuntimeException("The position of the Expression could not be calculated: " + expression); }
/** * {@inheritDoc} */ public void visit(JPQLExpression expression) { if (expression.hasQueryStatement()) { Expression queryStatement = expression.getQueryStatement(); queryStatement.accept(this); queryPosition.addPosition(expression, queryStatement.getLength() - correction); } else { queryPosition.setExpression(expression); queryPosition.addPosition(expression, 0); } }
/** * Calculates the position of the given expression by calculating the length of what is before. * * @param expression The expression to determine its position within the parsed tree * @return The length of the string representation of what comes before the given expression */ protected int position(Expression expression) { return expression.getOffset(); }
/** * {@inheritDoc} */ @Override protected void visit(Expression expression) { expression.acceptChildren(this); }
/** * Gets the select expression order. * * @param query * the query * @return the select expression order */ public ListIterable<Expression> getSelectExpressionOrder(KunderaQuery query) { if (!KunderaQueryUtils.isSelectStatement(query.getJpqlExpression())) { return null; } Expression selectExpression = ((SelectClause) (query.getSelectStatement()).getSelectClause()) .getSelectExpression(); List<Expression> list; if (!(selectExpression instanceof CollectionExpression)) { list = new LinkedList<Expression>(); list.add(selectExpression); return new SnapshotCloneListIterable<Expression>(list); } else { return selectExpression.children(); } }
/** * {@inheritDoc} */ @Override public void visit(JPQLExpression expression) { expression.getQueryStatement().accept(this); }
/** * {@inheritDoc} */ @Override public void visit(CoalesceExpression expression) { List<Expression> expressions = new ArrayList<Expression>(); List<Class<?>> types = new LinkedList<Class<?>>(); // Create the Expression for each scalar expression for (org.eclipse.persistence.jpa.jpql.parser.Expression child : expression.getExpression().children()) { child.accept(this); expressions.add(queryExpression); types.add(type[0]); // Set the type on an untyped ParameterExpression, so that // valid types can be passed for null parameter values in JDBC if (queryExpression.isParameterExpression()) { ParameterExpression paramExpression = (ParameterExpression) queryExpression; if (paramExpression.getType() == null || paramExpression.getType().equals(Object.class)) { paramExpression.setType(type[0]); } } } // Create the COALESCE expression queryExpression = queryContext.getBaseExpression(); queryExpression = queryExpression.coalesce(expressions); // Set the expression type type[0] = queryContext.typeResolver().compareCollectionEquivalentTypes(types); }
/** * Returns the length of the string representation of the given {@link Expression}. * * @param expression The {@link Expression} to retrieve the length of its string * @return The length of the string representation of the given {@link Expression} */ protected int length(Expression expression) { return expression.getLength(); }
/** * Calculates the position of the given {@link Expression} by calculating the length of what is before. * * @param expression The {@link Expression} for which its position within the parsed tree needs * to be determined * @param length The current cursor position within the JPQL query while digging into the tree * until the search reaches the expression * @return The length of the string representation for what is coming before the given {@link Expression} * @since 2.4 */ protected final int calculatePosition(Expression expression, int length) { Expression parent = expression.getParent(); // Reach the root if (parent == null) { return length; } // Traverse the child expression until the expression for (Expression childExpression : parent.orderedChildren()) { // Continue to calculate the position by going up the hierarchy if (childExpression == expression) { return calculatePosition(parent, length); } length += childExpression.getLength(); } // It should never reach this throw new RuntimeException("The position of the Expression could not be calculated: " + expression); }
/** * Calculates the position of the given expression by calculating the length of what is before. * * @param expression The expression to determine its position within the parsed tree * @return The length of the string representation of what comes before the given expression */ protected int position(Expression expression) { return expression.getOffset(); }
/** * {@inheritDoc} */ @Override protected final void visit(Expression expression) { expression.acceptChildren(this); } }
if (selExp.toActualText().indexOf(".") > 0) columns.add(selExp.toActualText().split("[.]")[1]); for (Expression exp : list) if (exp.toActualText().indexOf(".") > 0) columns.add(exp.toActualText().split("[.]")[1]);
Object inValues = kunderaQuery.getParametersMap().get(inClauseValues.toParsedText()); log.debug(inClauseValues.toParsedText() + "named parameter found in query, Replacing parameter with " + inValues); : (Collection) kunderaQuery.getParametersMap().get(inClauseValues.toParsedText()); inParameterCollection.add(value.toParsedText()); throw new KunderaException(inClauseValues.toParsedText() + " not supported for IN clause");