spring-projects / spring-projects/spring-data-rest
Provide documentation to integrate custom repository query in Spring Data Rest [DATAREST-642]
@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
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 :
- https://jira.spring.io/browse/DATAREST-206
- http://stackoverflow.com/questions/25201306/implementing-custom-methods-of-spring-data-repository-and-exposing-them-through
- http://stackoverflow.com/questions/26538156/can-i-make-a-custom-controller-mirror-the-formatting-of-spring-data-rest-sprin
- http://stackoverflow.com/questions/29570962/how-to-add-custom-methods-to-spring-data-rest-jpa-implementation-and-leverage-ha
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
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.