2011-05-10 56 views
0
class Book { 

String name 
String author  
static constraints = { name(nullable:true) 
} 
} 

上面似乎工作,但是当我把在多个领域的约束服务器启动不起来格姆实体约束

class Book { 

String name 
String author  
static constraints = { name(nullable:true) author(nullabe:false) 
} 
} 

与上面的代码......我得到的下面例外

所致:groovy.lang.MissingMethodException:方法的无签名:org.codehaus.groovy.grails.validation.ConstrainedPrope rty.call()是适用于参数类型:(org.codehaus.groovy .grails.va lidation.ConstrainedProperty)values:[org.codehau [email protected] [class com.nthdimenzion.domain.Book,author,class java.lang.String,{nulla ble = org.codehaus。 [email protected] [false]}]] 可能的解决方案:wait(),any(),wait(long),each(groovy.lang.Closure),any(groovy.lang.Closure), ISURL() 在com.nthdimenzion.domain.Book $ _ clinit _closure1.doCall(Book.groovy:16) 在com.nthdimenzion.domain.Book $ _ clinit _closure1.doCall(Book.groovy) ... 23更多

任何想法?

回答

4

它,因为你拥有了它在同一行...

尝试

static constraints = { 
    name(nullable:true) 
    author(nullabe:false) 
} 

编辑:

您可以阿洛斯分离与;的条目,那么你可以拥有一切在一个行,如果这是你想要的。 (但是我认为我们大多数人不使用线上...)

+0

谢谢你是这个问题:) – Sudarshan 2011-05-10 09:36:57