2009-03-23 15 views
7

मान लें मैं इस तरह एक Grails डोमेन वस्तु है:grails डिफ़ॉल्ट की कमी

class Todo { 

    String name 
    String status 

    static constraints = { 
     name(blank: false) 
    }  
} 

क्या होगा अगर एक मैदान पर डिफ़ॉल्ट की कमी कर रहे हैं:

  • यह उदा constraints ब्लॉक में सूचीबद्ध है नाम
  • यह constraints ब्लॉक में सूचीबद्ध नहीं है, उदा। स्थिति

उत्तर

11

हाँ, सिगफ्राइड सही है, शून्य है: झूठी एकमात्र चीज है जो डिफ़ॉल्ट रूप से सेट हो जाती है। आप डोमेन वर्ग शिल्पकृति पर एक नज़र डालें और कंसोल में विवश गुण पूछताछ कर सकते हैं:

grailsApplication.getDomainClass("Todo").constrainedProperties.each { propName, constraints -> 
    println "$propName : ${constraints.appliedConstraints.name}" 
} 

प्रिंटों:

status : [nullable] 
priority : [nullable] 
name : [blank, nullable] 
6

जहां तक ​​मुझे पता है कि यह दोनों मामलों में केवल nullable: false है।

संबंधित मुद्दे