2015-04-02 77 views
0

我有以下的Grails withCriteria結構:具有標準和/或案例的Grails?

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成績和和少校)scholarshipCounties活動specialTypeInd通過獎學金或或或。

回答

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