Reputation: 15909
i have a question about the inheritance possibilities of named queries. We would like to store some named queries in our abstract domain class like this.
abstract class AbstractDomain {
boolean state
static namedQueries = {
isActive{
eq("state", true)
}
}
}
class Person extends AbstractDomain {
String name
Integer age
static namedQueries = {
age18 {
eq("age", 18)
}
}
}
When we try to call the namedquery in Abstract domain it fails due to the fact that the closure block is overridden.
Person.isActive.age18 fails due to isActive not being present.
Can we reuse named queries in the Abstract Domain class?
Upvotes: 4
Views: 777
Reputation: 5540
Try this
class Person extends AbstractDomain {
String name
Integer age
static namedQueries = {
age18 {
eq("age", 18)
}
} << AbstractDomain.namedQueries
}
Upvotes: 5