Do you want to create a specification that matches all users with a group identifier that are in the groupsIds list?
If so, you can use something like this (which will use the SQL IN clause):
public static Specification<User> matchCompanyIdsList(final List<Long> groupIds){ return new Specification<User>() { public Predicate toPredicate(Root<User> root, CriteriaQuery<?> query, CriteriaBuilder builder){ final Path<Group> group = root.<Group> get("group"); return group.in(groupIds); } }; }
rchukh
source share