diff --git a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/QueryAQLConverter.java b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/QueryAQLConverter.java index f1ea0e3b7..834b609a7 100644 --- a/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/QueryAQLConverter.java +++ b/jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/QueryAQLConverter.java @@ -130,6 +130,7 @@ private static void definesCondition(CriteriaCondition condition, char entity, int counter) { Element document = condition.element(); + int localCounter = counter; switch (condition.condition()) { case IN: appendCondition(aql, params, entity, document, IN); @@ -157,27 +158,26 @@ private static void definesCondition(CriteriaCondition condition, for (CriteriaCondition dc : document.get(new TypeReference>() { })) { - if (isFirstCondition(aql, counter)) { + if (isFirstCondition(aql, localCounter)) { aql.append(AND); } - definesCondition(dc, aql, params, entity, ++counter); + definesCondition(dc, aql, params, entity, ++localCounter); } return; case OR: for (CriteriaCondition dc : document.get(new TypeReference>() { })) { - if (isFirstCondition(aql, counter)) { + if (isFirstCondition(aql, localCounter)) { aql.append(OR); } - definesCondition(dc, aql, params, entity, ++counter); + definesCondition(dc, aql, params, entity, ++localCounter); } return; case NOT: CriteriaCondition documentCondition = document.get(CriteriaCondition.class); - aql.append(NOT); - aql.append(START_EXPRESSION); - definesCondition(documentCondition, aql, params, entity, ++counter); + aql.append(NOT).append(START_EXPRESSION); + definesCondition(documentCondition, aql, params, entity, ++localCounter); aql.append(END_EXPRESSION); return; default: