使用Querydsl,Spring Data REST过滤嵌套集合不能正常工作

时间:2017-05-12 22:18:14

标签: spring-data-jpa spring-data-rest querydsl

基于@ StoreRepositoryOliver 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));
    }
}

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

我认为问题在于您没有在产品中指定属性名称。试试这个:

bindings.bind(store.products.any().name).first((path, value) -> path.eq(value));