• 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

JPA Criteria API and 'in' keyword

 
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I am learning Criteria API, particularly the 'in' keyword. Possible usages of this keyword in JPQL in 'where' clause are:
1. to check whether a single-valued path expression is a member of a collection ("select e from Employee e where e.age in (23, 24, 25)")
2. in a subquery (select e from Employee e where e.department in ("select d from Department d where d.name = 'Personnel Department')")

The 'in' keyword can also be used with the 'from' keyword where it represents a member of the collection in the multivalued association (i.e. one-to-many). A sample JPQL query is like this "select d, e from Department d, in(d.employees) e". Found in Java EE tutorial

The first two cases are quit straightforward to write via Criteria API. Could someone please advise, how to write the third query using Criteria API?
 
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic