First off, this is related to Spring Data Rest: How to search by another object's key? which appears to be resolved in https://jira.spring.io/browse/DATAREST-502
My issue is (I believe) and extension of this. I'm seeing the following behavior:
I have two repository queries defined e.g.
Person findByAccount(@Param("account") Account account)); Collection<Person> findByAccountIn(@Param("accounts") Collection<Account> accounts));
- Both search methods are exposed via spring-data-rest. I can access the first using a url such as
http://localhost:8080/people/search/findByAccount?account=http://localhost:8080/accounts/1
I can access the second method using a url such as
http://localhost:8080/people/search/findByAccountIn?accounts=http://localhost:8080/accounts/1
, but if I try to pass in MULTIPLE accounts, such ashttp://localhost:8080/people/search/findByAccountIn?accounts=http://localhost:8080/accounts/1,http://localhost:8080/accounts/2,
It will run the query except will IGNORE the first account (
http://localhost:8080/accounts/1
) and only search based on the second (http://localhost:8080/accounts/2
)
What is the proper technique for passing in a Collection of entities to a repository argument over the REST API? I find it works great for a single entity, but not for a Collection. Note that both of these repository methods are working as expected when directly accessing the JpaRepository.
Also note that these queries seem to work if the collection is of some primitive type, for example findByAccountIdIn(@Param("accountIds") Collection<Long> accountIds)
is accessible with intended functionality via http://localhost:8080/people/search/findByAccountIdIn?accountIds=1,2
. This leads me to believe it's possibly an error in the way a list of URIs is passed into a query method which expects a Collection of corresponding entities.
Thanks in advance for any help!