con*_*ile 6 grails grails-domain-class grails-2.0
在我的Grails域类中,我想设置在数据库中保留的默认值.我使用mysql作为数据库.我试着这样做:
class A {
long someValue = 1
long someOtherValue
boolean someBool = true
boolean someOtherBool
static mapping = {
someOtherValue defaultValue: 1
someOtherBool defaultValue: true
}
}
Run Code Online (Sandbox Code Playgroud)
但没有任何作用.数据库中没有设置默认值.我需要更改什么才能正确设置默认值?
如果您使用的是上面的Grails 2.2,那么您可以使用defaultValue.看看Burt的答案在这里 尝试一下,希望这会有所帮助:
Class A {
Long someValue
Long someOtherValue
Boolean someBool
Boolean someOtherBool
static mapping = {
someOtherValue defaultValue: 1
someOtherBool defaultValue: true
...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13150 次 |
| 最近记录: |