I have a domain class:
class Owner {
Integer ownerType
Prop propertyToJoinSometimes
static constraints = {
propertyToJoinSometimes nullable: true
}
}
I usually don't want to load propertyToJoinSometimes when loading Owner, but I sometimes load many Owner objects at once using findAllBy, and a join could save a large number of calls to the database. Is there a way to do something like:
Owner.findAllByOwnerType(2, [propertyToJoinSometimes: [fetch: 'join']])