Grails withCriteria和/或案件?

时间:2015-04-02 19:53:51

标签: grails gorm createcriteria

我有以下Grails withCriteria结构:

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

我希望通过(gpa和成绩和专业)或奖学金计划或活动或specialTypeInd返回奖学金。

1 个答案:

答案 0 :(得分:1)

您应该使用相应的or{}and{}条款:

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)
  }
}