I'm seeing some unexpected behavior in Grails' createCriteria. I have a domain class that looks like this:
MyDomainClass {
AnotherDomainClass anotherDomainClass
static constraints = {
anotherDomainClass(nullable:true)
}
}
I want to find all instances of MyDomainClass where anotherDomainClass is null. So I do this:
return MyDomainClass.createCriteria().list {
eq('anotherDomainClass', null)
}
However, I get nothing back.
What am I doing wrong? I can see there are database entries where the ANOTHERDOMAINCLASS_ID column is indeed null (or blank, I can't tell).
I'd be fine creating a query that references the ANOTHERDOMAINCLASS_ID column directly, but I haven't found a way yet.
Thanks!