How can i set default value in grails domain class

This will be possible in 2.2 which should be released this week or next. See http://jira.grails.org/browse/GRAILS-5520 for the relevant feature request. The syntax will be

static mapping = {
   name defaultValue: "'Cash'"
}

For now you’ll need to do what you’re doing – set the value as the default value of the field. You can manually update the database schema, or do the work as part of a migration.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)