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

Configuring entityLookup for MyEntity breaks /myEntities/id (can be fixed by registering a BackendIdConverter). [DATAREST-1487]

Open
#1,846 3 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

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

Description

jvanheesch opened DATAREST-1487 and commented

Please see reference url for quick reproducer.

1st commit: I defined entities Book and Author, book has an author, and all endpoints were working.
2nd commit: I configured EntityLookup for AuthorRepository, which breaks the /authors/2 endpoint, resulting in 

{
  "cause": null,
  "message": "class java.lang.String cannot be cast to class java.lang.Long (java.lang.String and java.lang.Long are in module java.base of loader 'bootstrap')"
}

3rd commit: I registered a BackendIdConverter for the Author class, which converts the String to a Long and vice versa, fixing /authors/2.

assume this is considered a bug. If it's not, the issue type may be changed to 'Improvement'


Reference URL: https://github.com/jvanheesch/spring-data-rest-entitylookup-backend-id-converter

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.