Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to combine two detachedCriteria with logical operators

avseq anthoy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • 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?

What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!