基于@ StoreRepository的Oliver Gierke
如果Store
的收藏品为products
/api/store?products.name=Sony%20Vaio
退货上有索尼Viao产品的商店很好,但所有产品都退回了, 我只需要名为Sony Viao的产品。
public interface StoreRepository extends PagingAndSortingRepository<Store, String>,
QueryDslPredicateExecutor<Store>, QuerydslBinderCustomizer<QStore> {
default void customize(QuerydslBindings bindings, QStore store) {
bindings.bind(store.products.any().first((path, value) -> path.equals(value));
}
}
任何帮助将不胜感激!
答案 0 :(得分:0)
我认为问题在于您没有在产品中指定属性名称。试试这个:
bindings.bind(store.products.any().name).first((path, value) -> path.eq(value));