Reputation: 1126
I grais 2.4.3 I have
class DomainFather {
Set domainSon = []
}
And
class DomainSon {
Date dataCreated
}
And I'm trying in a gorm criteria:
def c = DomainFather.createCriteria()
def data = c.list {
createAlias("domainSon", "ds")
projections {
max("ds.dataCreated", "ds")
}
}
Obviously does not work, but I have no idea how I'm supposed to do this. Any help is appreciate.
Upvotes: 0
Views: 310
Reputation: 9895
The problem is you didn't set up an association between the domain classes. Try this:
class DomainFather {
static hasMany = [sons: DomainSon]
}
Then you'll be able to use a query:
def c = DomainFather.createCriteria()
def data = c.list {
projections {
sons {
max("dataCreated")
}
}
}
Upvotes: 2