简体   繁体   中英

Grails domain property nullable - true by default?

Regarding setting a domain class property to be nullable, as described here: https://docs.grails.org/3.3.10/ref/Constraints/nullable.html

Is there a way to make "nullable equals true" to be the default for all properties in all my Grails domain classes? As opposed to the default for nullable being false.

As an additional note, I also have the property grails.databinding.convertEmptyStringsToNull = false in my application.yml file.

I'm on Grails 3.3.10.

You can define default constraints for all domain classes in grails-app/conf/application.groovy .

grails.gorm.default.constraints = {
    '*'(nullable: true)
}

See the Sharing Constraints section of the docs for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM