Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > pl.comp.lang.java > #10835
| X-Received | by 10.107.30.16 with SMTP id e16mr2978708ioe.22.1519242935097; Wed, 21 Feb 2018 11:55:35 -0800 (PST) |
|---|---|
| X-Received | by 10.157.95.135 with SMTP id g7mr210470oti.14.1519242935008; Wed, 21 Feb 2018 11:55:35 -0800 (PST) |
| Path | csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!w142no351174ita.0!news-out.google.com!s63ni1248itb.0!nntp.google.com!o66no350028ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | pl.comp.lang.java |
| Date | Wed, 21 Feb 2018 11:55:34 -0800 (PST) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=89.64.50.175; posting-account=3dQznAoAAAANJYk9IodTqzmaYUdPe9Je |
| NNTP-Posting-Host | 89.64.50.175 |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <79d5809b-cd5e-4522-8633-e3a6ecf3a8c4@googlegroups.com> (permalink) |
| Subject | unexpected AST node 'in' in Persistence Criteria API |
| From | rogal180@gmail.com |
| Injection-Date | Wed, 21 Feb 2018 19:55:35 +0000 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | quoted-printable |
| Lines | 38 |
| Xref | csiph.com pl.comp.lang.java:10835 |
Show key headers only | View raw
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