grails criteria query return empty result grails criteria query return empty result oracle oracle

grails criteria query return empty result


Change the 'and' to 'or' after 'childs'. Because, the logical 'or' tries to find the union between the two queries which would always be null.

List<Parent> parents = Parent.createCriteria().listDistinct {      and {          childs {              or {                  and {                      eq("gender", 2)                      ge("height", 150)                  }                  and {                      eq("gender", 1)                      le("height", 180)                  }              }          }      }  }

You can look at a github project I did inorder to illustrate this answer.