grails 3.3 detachedcriteria appears to give incorrect result

56 Views Asked by At

I have a self-referencing Grails 3.3.5 domain class of the form (simplified version)

class Animal {
    String name
    String dateOfBirth
    Animal sire
    Animal dam
}

I am using DetachedCriteria to build up a back-end query controlled by a JQuery tables .gsp front end that shows columns

name
dateOfBirth
sire.name
dam.name
dam.sire.name

and provides column filters on each column.

This all seems to be working as hoped-for except for one case: if I combine a filter value for sire.name and dam.sire.name no results are returned, ever (nor any error message or any other sign of distress).

The two related criterial builders look like this:

criteria = criteria.build {
    sire {
        ilike 'name', "%${v.search.value}%"
    }
}

and

criteria = criteria.build {
    dam {
        sire {
            ilike 'name', "%${v.search.value}%"
        }
    }
}

Just to be clear, filtering on dam.name and dam.sire.name works as expected, as does on name and dam.sire.name, sire.name and dam.name and so forth.

I am guessing that there is some interaction between the two joins to "sire", one inside the "dam" join.

Any ideas? Thanks in advance.

0

There are 0 best solutions below