I have some grails Domain classes that have relationships between them like so...
Domain A {
...
Domain B
}
Domain B {
...
Domain C
}
Domain C {
...
String name
String attr1
String attr2
}
How can I use withCriteria to perform eager fetching on A such that instances of B and C that are related to A are included in my results
like so...
List<A> aList = [..., B: [..., C: [... name: 'name', attr1: 'attr1', attr2: 'attr2']]]
The way you describe the expected results is a peculiar and I can't tell exactly what you want there...
The declared type of
aListsuggest you want aList<A>but the value you show looks like aMapwith some nestedMaps.If you execute a query like this...
What is returned from that will be a
ListofAand eachAwill reference aBand eachBwill reference aC.I hope that helps.
EDIT BASED ON COMMENT:
It is unclear if you want them to always be eagerly fetched or if you want to express that when you express the query. It sounds like maybe you want to express it when you express the query, which can be done like this...