I would like to return the 5 latest domain instances from 2 different tables. I have:
class Domain1 {
...
Date dateCreated
static mapping = {
sort "dateCreated"
}
...
}
&
class Domain2 {
...
Date dateCreated
static mapping = {
sort "dateCreated"
}
...
}
I need the 5 most recently created by dateCreated for any one user regardless of the table they come from, i.e if all 5 of the most recently created instances from a user are of type Domain1, then the query returns 5 Domain1 instances. I have looked at the various querying options available and haven't yet identified what could meet these needs (i haven't looked much at HQL). The user domain has a one to many relationship with the domains:
class User {
...
static hasMany = [domain1s:Domain1,
domain2s:Domain2,]
...
}