How can i set default value in grails domain class

后端 未结 3 1441
遥遥无期
遥遥无期 2021-02-05 00:27

Is there any way to set a default value to domain class property? I have a class called PayMethod, where I want the name property to default to \

3条回答
  •  忘了有多久
    2021-02-05 00:30

    Had the same issue and using static mapping didn't work for me either (using 2.2.3); the below link provided me a functional answer (set the default value in your object declarations):

    http://grails.1312388.n4.nabble.com/How-to-set-a-default-value-for-column-td1383753.html

    For String, encapsulate with quotes; int/integer should just be the value.

    Hope this helps!

提交回复
热议问题