0

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.

MonetsChemist
  • 165
  • 10
  • I don't understand the description above but if `DetachedCriteria` are yielding incorrect results, please file a bug report at https://github.com/grails/grails-data-mapping/issues and link to a sample app which demonstrates the problem and we will straighten it out. Thanks for the feedback. – Jeff Scott Brown May 03 '18 at 01:54
  • Thanks Jeff, I will work on that right away. – MonetsChemist May 03 '18 at 16:50
  • I'm going to file the bug report, but just for some closure here, I've found a very ugly workaround - if the detached criteria for dam/sire/name PRECEEDS that for sire/name, the criteria returns expected results; if the order is the other way around, the criteria returns no results. – MonetsChemist May 03 '18 at 20:33
  • The issue #1089 is now filed on GitHub. – MonetsChemist May 03 '18 at 21:12

0 Answers0