【发布时间】:2021-03-25 15:18:39
【问题描述】:
@Query("Select loc from Location loc where loc in :locations"
)
public Page<Location> searchLocations(List<Location> locations,
Pageable pageable);
然后当端点被调用时
https://localhost:8080/api/v1/stores/search/searchLocations?locations=https://localhost:8080/api/v1/locations/23,https://localhost:8080/api/v1/locations/24
只返回 24,而不是 23。
您如何实际向 JPA 查询提供列表参数?
【问题讨论】:
-
你试过了吗:
locations=https://localhost:8080/api/v1/locations/23&locations=https://localhost:8080/api/v1/locations/24 -
刚试过。同样的问题
-
我知道这适用于 QueryDsl 扩展。不知道你有没有看过。 Essentailly 将为您提供开箱即用的查询功能,而无需在存储库中创建搜索方法。不回答,但也许值得一看....
-
你是限制使用
List<Location>还是可以切换到数组Location[]? -
数组没问题,只要有办法调用端点
标签: spring-boot jpa spring-data spring-data-rest