0

I have the following Grails withCriteria structure:

allInfo = Scholarship.withCriteria {
    between('gpa', '0', gpa)
    grades {
      idEq year
    }
    scholarshipCounties {
        eq('county.id', county)
    }
    majors {
      idEq major
    }
    activities {
        idEq activity
    }
    eq('specialTypeInd', special)
}

I want this to return scholarships by (gpa AND grades AND majors) OR scholarshipCounties OR activities OR specialTypeInd.

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
connor moore
  • 611
  • 1
  • 8
  • 18

1 Answers1

1

you should be using respective or{} and and{} clauses:

allInfo = Scholarship.withCriteria {
  and{
    between('gpa', '0', gpa)
    grades {
      idEq year
    }
    majors {
      idEq major
    }
  }
  or{
    scholarshipCounties {
        eq('county.id', county)
    }

    activities {
        idEq activity
    }
    eq('specialTypeInd', special)
  }
}
injecteer
  • 20,038
  • 4
  • 45
  • 89