Abstract domain class and named queries inheritance?
سؤال
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?
المحلول
Try this
class Person extends AbstractDomain {
String name
Integer age
static namedQueries = {
age18 {
eq("age", 18)
}
} << AbstractDomain.namedQueries
}
لا تنتمي إلى StackOverflow