以下に示すように、IpPatient,Ward という名前の 2 つのドメイン クラスがあります。
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 のレコードがあり、病棟が null になる可能性があるため、8 つのレコードにIpPatient
は病棟がありません。
並べ替えるとwardName
、病棟を含む 5 つのレコードが取得されます。
null 許容内部オブジェクトで並べ替えを行った後、すべての要素を取得するための基準が必要です。