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

Provide documentation to integrate custom repository query in Spring Data Rest [DATAREST-642]

Open
#1,021 0 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: documentation
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Loïc Dewerchin opened DATAREST-642 and commented

When working with Spring Data JPA and Spring Data Rest there is often the need to add custom query to a repositories with a custom implementation.

How this is done is documented for the spring Data JPA part: http://docs.spring.io/spring-data/jpa/docs/1.8.2.RELEASE/reference/html/#repositories.custom-implementations

Now the question to integrate this into Spring Data Rest naturally arises , see :

So by gathering pieces of information you can conclude that :

  • you need to write your own rest endpoint and map it to your custom implementation
  • autowire PersistentEntityResourceAssembler as a RequestParameter, and use to create your representation of your result so that it matches hal+json output like SDR
  • implement ResourceProcessor<RepositorySearchesResource> to add your endpoint to the search resource ...

Seeing this is a common usecase, this could/should be properly documented in the SDR documentation.

Would save time for a lot of people. If needed I have a working example + documentation on our (private) wiki that I can share.


No further details from DATAREST-642

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.