In my Grails project, I have the following classes:
class A {
static hasMany = [cs:C]
}
class B {
static hasMany = [cs:C]
}
class C {
static belongsTo = [a:A, b:B]
}
I would like to query the class A and bring the all the associations from B and C eagerly. I tried the following criteria query, but when I iterate over Cs from A, hibernate uses lazy initialization to query B objects.
A.withCriteria() {
fetchmode "cs", FetchMode.JOIN
fetchMode "cs.b", FetchMode.JOIN
}
Any ideas?
one-to-many
and theFetchMode.SELECT
solved it for me. – Caesium