rsql-jpa-specification: Root join on @OneToMany property, not working while sorting in SortUtils.pathToExpression(final Root> root, final String path)
Hello dear RSQL JPA Spec team,
Hoping that your day is going well. I have the next Exception:
“An unexpected error occurred: Illegal attempt to dereference path source [null.criteria] of basic type” while trying to sort by a mapped property called qualityTarget
to criteria.qualityTarget
.
- 1st level, Root: Review.class
...
/** Criteria. */
@OneToMany(mappedBy = "review", cascade = CascadeType.ALL, orphanRemoval = true,
targetEntity = Criterion.class)
private List<Criterion> criteria = new ArrayList<>();
...
- 2nd Level: Criterion.class
...
/** Quality target. */
private String qualityTarget;
/** Review. */
@ManyToOne private Review review;
...
- Issue
Whenever I try to generate the
Expression
from the passed string path, it fails online 51
on the screenshot fromSortUtils.java
Could you please provide some insights, as we have the same approach in other classes that work, with the only difference that we only map properties to @OneToOne
relations, and not @OneToMany
like in this case with List<Criterion> criteria
.
Thanks in advance for any help and wish you a cool day ahead, Alan
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (9 by maintainers)
Hi @alancruzcgi, @perplexhub Sorry for long delay, was busy with main work activities. Check this PR - https://github.com/perplexhub/rsql-jpa-specification/pull/66
Hi @perplexhub @alancruzcgi I’ll review this issue over the weekend
https://ngdeveloper.com/illegal-attempt-dereference-path-source-null-categorylist-basic-type/
Could you try to change SortUtils line 49 from root.get to root.join?
@borsch Do you have any idea?
Hi Alan, could you share the exception, model classes and query? Thanks.