Grails 在对可为null的内部对象进行排序之后,我需要一个groovy标准来获取所有元素
我有两个名为IpPatient,Ward的域类,如下所示Grails 在对可为null的内部对象进行排序之后,我需要一个groovy标准来获取所有元素,grails,Grails,我有两个名为IpPatient,Ward的域类,如下所示 class IpPatient { String ipRegNo Ward ward static constraints = { ward nullable:true ipRegNo nullable:false } } class Ward { String name; static constraints = { name nullable:true } } 现在我想创建如
class IpPatient {
String ipRegNo
Ward ward
static constraints = {
ward nullable:true
ipRegNo nullable:false
}
}
class Ward
{
String name;
static constraints = {
name nullable:true
}
}
现在我想创建如下标准
def criteria=IpPatient.createCriteria()
return criteria.list(max:max , offset:offset) {
order("ward.name","asc")
createAlias('ward', 'ward', CriteriaSpecification.LEFT_JOIN)
}
目前,IpPatient
表有13条记录,其中,IpPatient
的8条记录没有病房,因为病房可以为空
当我使用wardName
进行排序时,我得到了5条包含ward的记录
在对可为null的内部对象进行排序后,我需要一个条件来获取所有元素。您可能不需要基于HQL的方法,但这应该可以做到:
IpPatient.findAll("from IpPatient as i left outer join i.ward as w order by w.name asc")
我需要的是标准@Andrew,而不是基于Hql的方法。