问题
I can retrieve one single book from Spring Data REST with a call such as: GET /book/{id}
Now, if I know the Ids of two books and I want to retrieve them all at once? What should the call be? I tried the following but it is returning me different books than the specified ones:
GET /book?ids=id1,id2
回答1:
You could declare a query method in your Repository interface like this:
List<Book> findByIdIn(@Param("ids") Long[] ids);
So that you can request books this way:
GET /book/search/findByIdIn?ids=1,6,9
来源:https://stackoverflow.com/questions/27013726/spring-data-rest-how-to-retrieve-many-items-using-list-of-ids-in-one-single-cal