spring-projects / spring-projects/spring-data-rest
RepositorySearchesResource resourceprocessor doesnt expose links unless search method has been put in repository class for custom search links [DATAREST-673]
Open
@odrotbohm is already working on this.
Since Dec 31, 2020.
in: repository
type: bug
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Gaurav Rawat opened DATAREST-673 and commented
Hi I am trying to expose a custom search method .So I do this via a @RepositoryRestcontroller something like below
@RequiredArgsConstructor
public class AbstractRsqlController<T, R extends BaseRepository<T, ? extends Serializable>>
implements
ResourceProcessor<RepositorySearchesResource>
{
/*
* (non-Javadoc)
* @see org.springframework.hateoas.ResourceProcessor#process(org.springframework.hateoas.ResourceSupport)
*/
public RepositorySearchesResource process(RepositorySearchesResource resource)
{
String path = entityLinks.linkFor(resource.getDomainType()).slash(SEARCH_LINK).toString();
resource.add(new Link(new UriTemplate(path + RSQL_QUERY_TEMPLATE), RSQL_REL));
return resource;
}
The code works fine but I dont see the search link on the entity unless I write a search method in the repository something like
public interface FundRepository extends BaseRepository<Fund, String> {
List<Fund> findByFoo(Boolean foo);
}
so unless the find by method is there the search link doesnt show up . Shouldnt including the RepositorySearchesResource type in ResourceProcessor work for custom links too ?
Affects: 2.4 GA (Gosling)
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.