2011-05-10 54 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