CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Object[]> query = criteriaBuilder.createQuery(Object[].class);
Root<ApiBudget> budget = query.from(ApiBudget.class);
Root<ApiAdGroups> adGroups = query.from(ApiAdGroups.class);
Root<ApiCampaigns> campaigns = query.from(ApiCampaigns.class);
Root<ApiUserAccount> userAccount = query.from(ApiUserAccount.class);
//this one is on your entity field name
query.select(criteriaBuilder.sum(budget.get("dailyBudget"));
List<Predicate> predicates = new ArrayList<Predicate>();
predicates.add(
qb.equal(adGroups.get("adGroupId"), budget.get("adGroupId")));
predicates.add(
qb.equal(campaigns.get("campaignId "), adGroups.get("campaignId")));
predicates.add(
qb.equal(userAccount.get("userId"), adGroups.get("userId")));
predicates.add(
qb.equal(adGroups.get("userId"), 234));
predicates.add(
qb.equal(adGroups.get("status"), 0));
predicates.add(
qb.equal(campaigns.get("status"), 1));
query.where(predicates.toArray(new Predicate[]{}));
query.groupBy(budget.get("dailyBudget"));
TypedQuery<Object[]> typedQuery = entityManager.createQuery(query);
List<Object[]> resultList = typedQuery.getResultList();
Привет, я думаю, что это должно работать