How to add constraints on inherited properties in a grails domain sub-class

前端 未结 4 936
没有蜡笔的小新
没有蜡笔的小新 2021-01-01 12:05

Here\'s what I\'d like to do:

class A {
  String string
  static constraints = {
    string(maxSize:100)
  }
}

class B extends A {
  static constraints = {
         


        
4条回答
  •  抹茶落季
    2021-01-01 12:36

    The way it was in 2.x:

    As constraints is a closure executed by some ConstraintsBuilder, I'd try calling it from B, like

    class B extends A { 
      static constraints = { 
        url(unique: true)
        A.constraints.delegate = delegate  # thanks Artefacto
        A.constraints()
      } 
    }
    

提交回复
热议问题