CriteriaBuilder select ManyToMany

I have such code

@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
public Registration getRegistration() {
    return registration;

@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "COMPANY_USER", joinColumns = @JoinColumn(name = "USER_ID", referencedColumnName = "ID"), inverseJoinColumns = @JoinColumn(name = "COMPANY_ID", referencedColumnName = "ID"))

public List<CompanyInfo> getCompanyInfoList() {
    return companyInfoList;

For exmaple in Registration (@OneToOne) I search so

private Predicate[] buildPredicates(UserFilter example, CriteriaBuilder qb, Root root) {
    ArrayList<Predicate> predicates = new ArrayList<>();
    if (example != null) {
    predicates.add(, "%TEST%"));
    return predicates.toArray(new Predicate[predicates.size()]);

And how to correctly search in the List CompanyInfo (@ManyToMany)

predicates.add( ??

For example I want get such sql

SELECT, u.login_name,
  FROM user_info  u
       INNER JOIN company_user cu ON cu.user_id =
       INNER JOIN company_info c ON cu.company_id =

company_user is Link table.

With CriteriaBuilder

    CriteriaBuilder qb = em.getCriteriaBuilder();
    CriteriaQuery<Long> query = qb.createQuery(Long.class);
    Root<UserInfo> root = query.from(UserInfo.class);;

    Subquery<String> subquery = query.subquery(String.class);
    Root<CompanyInfo> subRoot = subquery.from(CompanyInfo.class);;

    List<Predicate> restrictions = buildPredicates(example, qb, root);
    List<Predicate> restrictionsSub = buildPredicatesSub(example, qb, subRoot);
    Predicate[] predicates = joinList(restrictions, restrictionsSub);

    return em.createQuery(query.distinct(true)).getSingleResult();

Try this, Entity_A and Entity_B are the manyToMany associated entities:

Join<Entity_A, Entity_B> join = root.join("associationList", JoinType.INNER);
predicates.add("name").as(String.class), "%test%"));