I am working on a Grails project using Hibernate (GORM). I have the following domain models:
ClientContact {
static hasMany = [owners: Person]
static belongsTo = [Person]
}
Person {
static hasMany = [clientContacts: ClientContact]
}
When I try to get everything ClientContactswith a specific owner ( Person), I run into some funny problems. I use the following query criteria:
def query = {
owners {
eq("id", Long.parseLong(params.ownerId))
}
}
def criteria = ClientContact.createCriteria()
def results = criteria.list(params, query)
The problem is that when I repeat each of mine ClientContactsin the results, they have only one owner - when in fact most have many other owners. What gives? I know that hibernate / GORM uses a lazy choice, but I thought that he would come all the other owners on ClientContactwhen I try to access them.
? list(), .