Spring Data Rest: pass Collection<Entity> as query String parameter -
first off, related spring data rest: how search object's key? appears resolved in https://jira.spring.io/browse/datarest-502
my issue (i believe) , extension of this. i'm seeing following behavior:
i have 2 repository queries defined e.g.
person findbyaccount(@param("account") account account)); collection<person> findbyaccountin(@param("accounts") collection<account> accounts));
- both search methods exposed via spring-data-rest. can access first using url such
http://localhost:8080/people/search/findbyaccount?account=http://localhost:8080/accounts/1
i can access second method using url such
http://localhost:8080/people/search/findbyaccountin?accounts=http://localhost:8080/accounts/1
, if try pass in multiple accounts, suchhttp://localhost:8080/people/search/findbyaccountin?accounts=http://localhost:8080/accounts/1,http://localhost:8080/accounts/2,
it run query except ignore first account (
http://localhost:8080/accounts/1
) , search based on second (http://localhost:8080/accounts/2
)
what proper technique passing in collection of entities repository argument on rest api? find works great single entity, not collection. note both of these repository methods working expected when directly accessing jparepository.
also note these queries seem work if collection of primitive type, example findbyaccountidin(@param("accountids") collection<long> accountids)
accessible intended functionality via http://localhost:8080/people/search/findbyaccountidin?accountids=1,2
. leads me believe it's possibly error in way list of uris passed query method expects collection of corresponding entities.
thanks in advance help!
try repeat query parameter servers interpret list. might not prettiest solution should work.
http://localhost:8080/people/search/findbyaccountin?accounts=http://localhost:8080/accounts/1&accounts=http://localhost:8080/accounts/2
Comments
Post a Comment