Closed jfb-NRB closed 2 months ago
we have the same problem with reducing the query path with RSQLCommonSupport.addMapping(..)
here is an example which produces this error: https://github.com/jdmmnn/rsql-embedded-bug-repository/tree/master
2024-07-11T09:40:22.776+02:00 INFO 26697 --- [ Test worker] i.g.perplexhub.rsql.RSQLCommonSupport : Adding entity class mapping for class com.example.demo.entity.AccountEntity, selector invoiceAddress and property addressHistory.invoiceAddress
Unknown property: name from entity com.example.demo.entity.AccountEntity
io.github.perplexhub.rsql.UnknownPropertyException: Unknown property: name from entity com.example.demo.entity.AccountEntity
at io.github.perplexhub.rsql.RSQLJPAPredicateConverter.findPropertyPathInternal(RSQLJPAPredicateConverter.java:101)
at io.github.perplexhub.rsql.RSQLJPAPredicateConverter.findPropertyPath(RSQLJPAPredicateConverter.java:73)
at io.github.perplexhub.rsql.RSQLJPAPredicateConverter.resolveExpression(RSQLJPAPredicateConverter.java:235)
at io.github.perplexhub.rsql.RSQLJPAPredicateConverter.visit(RSQLJPAPredicateConverter.java:211)
at io.github.perplexhub.rsql.RSQLJPAPredicateConverter.visit(RSQLJPAPredicateConverter.java:24)
at cz.jirutka.rsql.parser.ast.ComparisonNode.accept(ComparisonNode.java:67)
at io.github.perplexhub.rsql.RSQLJPASupport.lambda$toSpecification$7eef092d$1(RSQLJPASupport.java:135)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.applySpecificationToCriteria(SimpleJpaRepository.java:841)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:760)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:745)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:449)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
......
Hi @tobjohnbx, thanks for your detailed report.
it is merged with https://github.com/perplexhub/rsql-jpa-specification/pull/159
Is it possible to do the same fix on version 5.x because our project is still in SpringBoot 2. Thanks in advance.
Is it possible to do the same fix on version 5.x because our project is still in SpringBoot 2. Thanks in advance.
5.1.2
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.
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:
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