• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do criteria API and subqueries work?

 
Ranch Hand
Posts: 82
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I'm so happy! And I wish to make this tiny ad happy too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic