Fix RSQL G2 visitor and referenes (e.g. assignedds) with multiple conditions (#2405)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -296,8 +296,9 @@ public class JpaQueryRsqlVisitorG2<A extends Enum<A> & RsqlQueryField, T>
|
||||
// see org.eclipse.persistence.internal.jpa.querydef.FromImpl implementation for more details when root.get creates a join
|
||||
final Attribute<?, ?> attribute = root.getModel().getAttribute(fieldNameSplit);
|
||||
if (!attribute.isCollection()) {
|
||||
// it is a SingularAttribute and not join if it is of basic persistent type
|
||||
if (((SingularAttribute<?, ?>) attribute).getType().getPersistenceType().equals(Type.PersistenceType.BASIC)) {
|
||||
// it is a SingularAttribute and not join if it is of basic or entity persistence type
|
||||
final Type.PersistenceType persistenceType = ((SingularAttribute<?, ?>) attribute).getType().getPersistenceType();
|
||||
if (persistenceType.equals(Type.PersistenceType.BASIC) || persistenceType.equals(Type.PersistenceType.ENTITY)) {
|
||||
return root.get(fieldNameSplit);
|
||||
}
|
||||
} // if a collection - it is a join
|
||||
|
||||
@@ -41,6 +41,7 @@ class RSQLToSQLTest {
|
||||
|
||||
private RSQLToSQL rsqlToSQL;
|
||||
|
||||
|
||||
@Test
|
||||
void print() {
|
||||
print(JpaTarget.class, TargetFields.class, "tag==tag1 and tag==tag2");
|
||||
@@ -51,18 +52,23 @@ class RSQLToSQLTest {
|
||||
|
||||
@Test
|
||||
void printSimple() {
|
||||
// simple - column in table
|
||||
print(JpaTarget.class, TargetFields.class, "controllerId==ctrlr1");
|
||||
print(JpaTarget.class, TargetFields.class, "targettype.key==type1");
|
||||
// reference - fk to a table
|
||||
print(JpaTarget.class, TargetFields.class, "assignedds.name==x and assignedds.version==y");
|
||||
// list of non-simple (with mapping table)
|
||||
print(JpaTarget.class, TargetFields.class, "tag==tag1");
|
||||
print(JpaTarget.class, TargetFields.class, "metadata.key1==value1");
|
||||
// list (map table that refers main)
|
||||
print(JpaTarget.class, TargetFields.class, "attribute.key1==value1");
|
||||
// map (map table that refers main)
|
||||
print(JpaTarget.class, TargetFields.class, "metadata.key1==value1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void printAnd() {
|
||||
print(JpaTarget.class, TargetFields.class, "controllerId==ctrlr1 and controllerId==ctrlr2");
|
||||
print(JpaTarget.class, TargetFields.class, "targettype.key==type1 and targettype.key==type2");
|
||||
print(JpaTarget.class, TargetFields.class, "tag==tag1 and tag==tag2 and tag=tag3");
|
||||
print(JpaTarget.class, TargetFields.class, "tag==tag1 and tag==tag2 and tag==tag3");
|
||||
print(JpaTarget.class, TargetFields.class, "metadata.key1==value1 and metadata.key2==value2");
|
||||
print(JpaTarget.class, TargetFields.class, "attribute.key1==value1 and attribute.key2==value2");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user