【问题标题】:Spring querydsl predicate: relationship supportSpring querydsl谓词:关系支持
【发布时间】:2018-04-06 05:45:36
【问题描述】:

我有一个与联系人有 OneToOne 关系的客户实体。 如果我想获取客户名称,我需要写:

 client.getContact().getLastName()

我使用 querydsl lib 在我的 Spring Boot 应用程序中过滤客户端列表

 /api/clients?contact.lastName=Doe

我的控制器签名:

 public ResponseEntity<ResponseListDTO> getClients (
        @QuerydslPredicate(root = Client.class) Predicate predicateClient,
        Pageable pageable)

它运行良好:谓词创建良好,过滤器运行良好。

但现在我需要过滤两个关系级别内的字段:

 client.getContact().getAddress().getCity()

所以我不想写:

 /api/clients?contact.address.city=XXX

但它没有与@QuerydslPredicate 映射。没有错误,但 @QuerydslPredicate 谓词仍然为空(如果没有过滤器)。

谢谢!

【问题讨论】:

    标签: java spring spring-boot spring-data querydsl


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 2015-01-21
      • 2016-01-08
      • 1970-01-01
      • 2020-09-18
      • 2022-08-10
      • 1970-01-01
      • 2020-09-23
      • 1970-01-01
      • 2017-03-15
      相关资源
      最近更新 更多