rsql-jpa-specification icon indicating copy to clipboard operation
rsql-jpa-specification copied to clipboard

Throws an unknown property exception when i reduce the path by using the property map.

Open jfb-NRB opened this issue 8 months ago • 0 comments

Hello,

I have a structure where a user has multiples roles, but in our database, the relationship between user and role is in a user_role_rel table because this table has additional fields like creationDate.

public class User {
private Date creationDate;
@OneToMany
private Set<UserRoleRel> userRoleRels;
}

public class UserRoleRel {
private Date creationDate;
@ManyToOne
private Role role;
}

public class Role {
private Date creationDate;
private int roleId;
}

If we filter users with a roleId, the classic path is "userRoleRels.role.roleId" and that's OK. But I would like to simplify the path with "roles.roleId" and hide the relationship table by adding a property mapping to User like this:

RSQLJPASupport.addMapping(User.class, "roles", "userRoleRels.role");

I received the exception: Unknown property: roleId from entity User

I used version 5.x and the problem may be with the RSQLJPAPredicateConverter class in the findPropertyPath function . When the function is called by recursion, the root and attribute variables are set but not the classMetadata.

Thanks for your follow-up

Regards

jfb-NRB avatar May 30 '24 14:05 jfb-NRB