I need a groovy criteria to get all the elements after i make sort on nullable inner object
- by user1773876
I have two domain classes named IpPatient,Ward as shown below.
class IpPatient {
String ipRegNo
Ward ward
static constraints = {
ward nullable:true
ipRegNo nullable:false
}
}
class Ward
{
String name;
static constraints = {
name nullable:true
}
}
now i would like to create criteria like
def criteria=IpPatient.createCriteria()
return criteria.list(max:max , offset:offset) {
order("ward.name","asc")
createAlias('ward', 'ward', CriteriaSpecification.LEFT_JOIN)
}
At present IpPatient table has 13 records, where 8 records of IpPatient doesn't have ward because ward can be null.
when i sort with wardName i am getting 5 records those contain ward.
I need a criteria to get all the elements after i make sort on nullable inner object.