• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do criteria API and subqueries work?

 
daniele licitra
Ranch Hand
Posts: 81
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all.

I want to make a query using Criteria API. I use EclipseLink to auto-create metaclass. The query, in a jpql like syntax, is:


The java code I wrote is:


The query without the subquery works.

First problem:
in subquery, the table is called DN_THIS like the table in the main query. For example, the HAVING clause must be HAVING v.codtessera = a.codtessera, but the code
qpremio.having(cb.equal(vendcod, card.get(Anagraficacard_.codtessera)));
produces
HAVING (DN_THIS.codtessera = DN_THIS.codtessera)

How do I specify two different name for two different entity/table? Is there something wrong?

Second problem:
the query must be
WHERE ... AND (subquery) >= 20
How do I create a predicate like that? I haven't found any example
I need a predicate because i specify filter by a jsf mask with a lot of filter-options that need also other subqueries.

Thanks in advance
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic