spring-projects / spring-projects/spring-data-rest
Add support for query methods returning a projection [DATAREST-841]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Oliver Drotbohm opened DATAREST-841 and commented
Currently Spring Data REST does not support returning projections from query methods directly. The feature has been introduced for Spring Data JPA and MongoDB in the Hopper release train and it would be cool to get this working in Spring Data REST, too.
Currently the problem is that PersistentEntityResourceAssembler and a couple of downstream components try to lookup a PersistentEntity for the returned instance's type which fails due to the proxy type being used and not the underlying target class. Even if that's fixed, the question is how we can make sure to be able to create self links properly as the identifier property is not guaranteed to be exposed by the proxy and contrary to the projection mechanism applied by Spring Data REST the proxy might not be backed by the actual domain object.
For DTOs used, we might even run into problems in the MappingContext as e.g. JPA currently only considers managed types a PersistentEntity
Issue Links:
- DATAREST-1257 Spring Data Projection doesn't work when using with Page
("is duplicated by") - DATAREST-1054 Exposing projections from query methods on the repository level
("is duplicated by") - DATAJPA-885 No aliases found in result tuple
8 votes, 10 watchers
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.