diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/JpaQueryRsqlVisitorG2.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/JpaQueryRsqlVisitorG2.java index ac50e01505..692fc233d6 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/JpaQueryRsqlVisitorG2.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/rsql/JpaQueryRsqlVisitorG2.java @@ -71,7 +71,7 @@ public class JpaQueryRsqlVisitorG2 & RsqlQueryField, T> private final boolean ensureIgnoreCase; private final SimpleTypeConverter simpleTypeConverter = new SimpleTypeConverter(); - private final Map, Path> javaTypeToPath = new HashMap<>(); + private final Map> attributeToPath = new HashMap<>(); private boolean inOr; public JpaQueryRsqlVisitorG2(final Class enumType, @@ -100,7 +100,7 @@ public List visit(final OrNode node, final String param) { return Collections.singletonList(children.isEmpty() ? cb.conjunction() : cb.or(children.toArray(new Predicate[0]))); } finally { inOr = false; - javaTypeToPath.clear(); + attributeToPath.clear(); } } @@ -303,7 +303,7 @@ private Path getPath(final Root root, final String fieldNameSplit) { } } // if a collection - it is a join if (inOr && root == this.root) { // try to reuse join of the same "or" level and no subquery - return javaTypeToPath.computeIfAbsent(attribute.getJavaType(), k -> root.join(fieldNameSplit, JoinType.LEFT)); + return attributeToPath.computeIfAbsent(attribute.getName(), k -> root.join(fieldNameSplit, JoinType.LEFT)); } else { return root.join(fieldNameSplit, JoinType.LEFT); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLToSQLTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLToSQLTest.java index 098ae0c9ff..64d08f6822 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLToSQLTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLToSQLTest.java @@ -36,12 +36,12 @@ @ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class }) @Import(TestChannelBinderConfiguration.class) @Disabled("For manual run only, while playing around with RSQL to SQL") -public class RSQLToSQLTest { +class RSQLToSQLTest { private RSQLToSQL rsqlToSQL; @Test - public void print() { + void print() { print(JpaTarget.class, TargetFields.class, "tag==tag1 and tag==tag2"); print(JpaTarget.class, TargetFields.class, "tag==tag1 or tag==tag2 or tag==tag3"); print(JpaTarget.class, TargetFields.class, "targettype.key==type1 and metadata.key1==target1-value1"); @@ -49,7 +49,12 @@ public void print() { } @Test - public void printPG() { + void printSameTableMultiJoin() { + print(JpaTarget.class, TargetFields.class, "installedds.version==1.0.0 or assignedds.version==2.0.0"); + } + + @Test + void printPG() { printFrom(JpaTarget.class, TargetFields.class, "tag!=TAG1 and tag==TAG2"); printFrom(JpaTarget.class, TargetFields.class, "tag==TAG1 and tag!=TAG2"); }