spring-projects / spring-projects/spring-data-rest

Add support for query methods returning a projection [DATAREST-841]

Open
#1,213 4 comments 1 reaction 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

in: repository type: enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.