Help coderanch get a
new server
by contributing to the fundraiser
  • 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

How to combine two detachedCriteria with logical operators

Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all , I have two available two detachedCriteria as below

Now I want to reuse these two detachedCriteria to get the student that age above 20 or age below 10.

My current way is

The code will use two separate sql to get the student data( 1. get student age above 20 , 2. get student age below 10).

I want to let hibernate use one sql to get the data (student age above 20 or student age below 10).
But the code can't work, because the parameter type of Restrictions.or is Criterion.

Can somebody teach me how to combine two availabe detachedCriteria with logical operators?

please buy this thing and then I get a fat cut of the action:
We need your help - Coderanch server fundraiser
    Bookmark Topic Watch Topic
  • New Topic