spring-projects / spring-projects/spring-data-rest
Methods provided by a custom generic repository appear under /search but are not working [DATAREST-102]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Michael Wilmes opened DATAREST-102 and commented
The following repository
public interface BcsRepository extends AssetRepository<Bcs> {
}
extends from this generic repository
public interface AssetRepository<T> extends GraphRepository<T> {
@Query("start n=node:uuid(uuid={uuid}) return n")
T findByUuid(@Param("uuid") String uuid);
@Query("start n=node:search(name={name}) return n")
Collection<T> findByName(@Param("name") String name);
}
Both methods mapped via REST...
{
"links": [
{
"rel": "bcs.findByUuid",
"href": "http://localhost:8080/api/bcs/search/findByUuid"
},
{
"rel": "bcs.findByName",
"href": "http://localhost:8080/api/bcs/search/findByName"
}
],
"content": []
}
...but requests fail with
{
"cause": null,
"message": "object is not an instance of declaring class"
}
If I don't extend from the custom generic class and put the methods into BcsRepository directly requests work as intended.
Is there any possibility to have those methods extended from generic repositories be exposed correctly with SDR?
Affects: 2.0 M1 (Codd)
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.
Research direction
Start by reproducing the issue with BcsRepository extending the generic AssetRepository and compare it with methods declared directly on BcsRepository. Trace the REST search-method invocation for findByUuid and findByName; done means both inherited methods remain listed under /search and requests no longer fail with "object is not an instance of declaring class".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100