【发布时间】:2013-06-10 07:27:34
【问题描述】:
我正在从数据库中获取结果列表,但列表不会验证约束,直到我为每个对象调用“validate()”方法。
def temp = ConfigInfo.where { projectId == project }.findAll()
//at this stage domain class is not validated
temp.each {
println "validate" + it.validate()
println "has error" + it.hasErrors()
}
//in the above code block validate() is called, I don't want to do this.
// 是否可以自动配置它并且我得到验证的对象。
我不想调用 validate 方法。 grails中是否有任何方法或配置可以自动验证域类。
请帮帮我。
【问题讨论】:
-
如果您从表中获取数据并且不更改值,为什么需要再次验证它?
标签: grails-orm grails-2.0 grails-domain-class