我有以下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 AND成绩和专业)或奖学金国家或 Activity 或specialTypeInd的奖学金。
最佳答案
您应该分别使用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)
}
}