Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > pl.comp.lang.java > #10835
| Newsgroups | pl.comp.lang.java |
|---|---|
| Date | 2018-02-21 11:55 -0800 |
| Message-ID | <79d5809b-cd5e-4522-8633-e3a6ecf3a8c4@googlegroups.com> (permalink) |
| Subject | unexpected AST node 'in' in Persistence Criteria API |
| From | rogal180@gmail.com |
Hi,
I have problem with fetch count item by predicate:
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> countQuery = criteriaBuilder.createQuery(Long.class);
Root<Application> countApplicationRoot = countQuery.from(Application.class);
countQuery.select(criteriaBuilder.count(countApplicationRoot));
countQuery.where(getPredicates(criteriaBuilder, countApplicationRoot));
Long count = entityManager.createQuery(countQuery).getSingleResult();
private Predicate[] getPredicates(CriteriaBuilder builder, Root<Application> root) {
List<Predicate> predicateList = new ArrayList<>();
CriteriaQuery<Application> ownReceiverCriteriaQuery = builder.createQuery(Application.class);
Root<ReceiverServiceClient> ownReceiverRoot = ownReceiverCriteriaQuery.from(ReceiverServiceClient.class);
Predicate ownReceiverCondition = builder.equal(root.get(Application_.user).get(User_.clients)
.in(ownReceiverRoot.get(ReceiverServiceClient_.receiverService).get(ReceiverService_.systemName)), SystemName.valueOf("WP_PL"));
predicateList.add(ownReceiverCondition);
return predicateList.toArray(new Predicate[predicateList.size()]);
}
gets an error:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: in near line 1, column 118 [select count(generatedAlias0) from com.crud.entity.Application as generatedAlias0 where generatedAlias0.user.clients in (generatedAlias1.receiverService.systemName)=:param0]
Has anyone had a similar problem and knows how to solve it?
Back to pl.comp.lang.java | Previous | Next | Find similar
unexpected AST node 'in' in Persistence Criteria API rogal180@gmail.com - 2018-02-21 11:55 -0800
csiph-web