热在jpa Criteria中添加另一个对象的参数列表

Hot to add a list of parameters of another object in jpa Criteria

我有一位class导演

   public class Director {
      private Long id;

      @OneToOne(cascade = CascadeType.ALL)
      @JoinColumn(name="transacao_id")
      private Company company;
      private Date registrationDate;

       ...
   }

我有一家class公司

   public class Company {
      private Long id;
      private String cnpj;
      private String description;

       ...
   }

我需要在谓词中添加另一个过滤器...

我需要从 Director 中获取一个列表,使用 jpa 谓词过滤 cnpj 的 列表,例如:

private Predicate[] criarRestricoes(FilterDTO filter, CriteriaBuilder builder, Root<Director> root) {

        List<Predicate> predicates = new ArrayList<>();
        Date today = new Date();

        if (filter.getRegistrationDate() != null) {

            predicates.add(builder.between(root.get("registrationDate").as(Date.class), today, filter.dateParam));

        } 

       if (!StringUtils.isEmpty(filter.getCnpj())) {

            predicates.add(builder.equal(???????????, ???????????????);

        } 

        return predicates.toArray(new Predicate[predicates.size()]);
    }
builder.equal(root.join("company").get("cnpj"), filter.getCnpj());