动态使用数据库查询定义inList约束

时间:2014-07-06 17:40:26

标签: grails groovy

我正在尝试实现类似的东西,但错误正在提升:

PersonController.Groovy

class PersonController
{
    static scaffold = Person
}

Person.groovy

class Person
{
    String function

    static constraints = {
        function  (inList:[Function.findAllByType("JENKIN")])
    }
}

抛出异常:

...
Caused By: Method on class [com.test.domain.Person] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
...

可以在inList约束中使用findBy方法吗?

由于

0 个答案:

没有答案