我有一个域结构,如下所示
class Parent { static hasMany = [childs:Child] } class Child { int gender string height }
现在,我想得到所有父母的名单,他们有一个男孩(性别= 1),身高低于’180’cm,女孩(性别= 2)身高超过’150’cm.
我尝试了下面给出的标准
def criteria = Parent.createCriteria() def parents = criteria.list() { childs { and { and { eq("gender",2) ge("height",150) } and { eq("gender",1) le("height",180) } } } } }
但它返回一个空列表,尽管有有效数据.