Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findBy + @Param expects an Id, which is not visible via REST [DATAREST-599] #973

Closed
spring-projects-issues opened this issue Jun 27, 2015 · 5 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jun 27, 2015

Oliver Trosien opened DATAREST-599 and commented

Hi,

here is another issue I came across while trying out Spring Data REST:
IDs are, if I'm correct, intentionally not exposed in the resource body, as you're supposed to use the URL as primary identifier.

This is a problem, because by exposing a repository finder Spring Data REST expects me to put the primary key as query param.

I put up a small example on github:

https://github.com/otrosien/spring-data-examples/tree/findQueryParamMismatch

This is the interesting part: How am I, as REST client, suppose to fill the query param for customer1?

public interface RelationshipRepository extends PagingAndSortingRepository<Relationship, Long> {
 Page<Relationship> findByCustomer1(@Param("customer1") Customer customer1, Pageable pageable);

Issue Links:

  • DATAREST-502 Not convenient to search a repository by a related entity using links
    ("duplicates")
@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 16, 2015

Oliver Trosien commented

ping - any thoughts on this? Is there a conceptual mismatch or am I doing something wrong?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 16, 2015

Oliver Drotbohm commented

If Customer is a managed type, a REST client will have to provide an identifier for customer1. Identifiers in a REST world are – as the name suggests – URIs. So that's what you'd submit

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 16, 2015

Oliver Trosien commented

Thanks for the reply. I'm aware of using the URI as identifier, but that's not the way Spring Data REST is rendering the resource for the finder at the moment. It is putting customer1 as query param, and there I am expected to put the internal ID, that's at least what I'm seeing here.

The UriTemplate looks like this (iirc):
/relationships/search/findByCustomer1{?page,size,sort,customer1}

I tried putting the customer1 URI as query param, but that didn't work. It only worked putting the internal ID there.

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 17, 2015

Oliver Drotbohm commented

That seems to have been fixed for DATAREST-502 already available in Gosling M1. Would you mind to give that a spin?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 17, 2015

Oliver Trosien commented

@ogierke: You're right. This is a duplicate of DATAREST-502. It works in M1 and thus can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants