如何在Grails 2.2中为Domain Class Values设置默认值?

在我的Grails域类中,我想设置在数据库中保留的认值.我使用 mysql作为数据库.我试着这样做:
class A {

   long someValue = 1
   long someOtherValue
   boolean someBool = true
   boolean someOtherBool

   static mapping = {
      someOtherValue defaultValue: 1
      someOtherBool defaultValue: true  
   }
}

但没有任何作用.数据库中没有设置认值.我需要更改什么才能正确设置认值?

解决方法

如果您使用的是上面的Grails 2.2,那么您可以使用defaultValue.看看伯特的答案 here
尝试一下,希望这会有所帮助:
Class A {
      Long someValue 
      Long someOtherValue

      Boolean someBool
      Boolean someOtherBool

     static mapping = {
        someOtherValue defaultValue: 1
        someOtherBool  defaultValue: true  
        ...
     } 

}

相关文章

vue阻止冒泡事件 阻止点击事件的执行 <div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些