문제

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
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top