Grails nullable:true not working after modifying domain class

天大地大妈咪最大 提交于 2020-02-25 02:37:22

问题


I have a domain class with few fields. The application was running and then I had to add 2 more fields to the domain class which were marked as nullable:

class SomeDomain{
   // Fields from beginning
   .............
   // Two fields added afterwards
   String fieldA
   String fieldB
   static constraints = {
     // Constraints on initial fields
     ...............
     // Constraints on fields added afterwards
     fieldA(nullable: true)
     fieldB(nullable: true)
   }

}

But when I run this, then I see the fields added to mysql table. But they don't have the nullable constraint. So its not allowing nulls in those fields. What could be the reason and is there any way to solve this. Obviously I can edit the mysql tables directly to add the Nullable property to those two fields. However I want to know why it create the two fields in the table, but failed to add the null constraint(so that in future I can avoid such errors).

I am using Grails 2.2.1.

来源:https://stackoverflow.com/questions/31178945/grails-nullabletrue-not-working-after-modifying-domain-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!