Article View: pl.comp.lang.java
Article #154301unexpected AST node 'in' in Persistence Criteria API
From: rogal180
Date: Wed, 21 Feb 2018 19:55
Date: Wed, 21 Feb 2018 19:55
30 lines
2894 bytes
2894 bytes
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?
Technical Details
Message-ID:
<79d5809b-cd5e-4522-8633-e3a6ecf3a8c4@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!peer03.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.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-mailShow Full Headers
Complete Article Headers
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: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!peer03.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.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> Subject: unexpected AST node 'in' in Persistence Criteria API From: rogal180@gmail.com Injection-Date: Wed, 21 Feb 2018 19:55:35 +0000 Lines: 38 X-Received-Bytes: 2727 X-Received-Body-CRC: 1034330427 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit