【问题标题】:Abstract domain class and tablePerHierarchy抽象域类和 tablePerHierarchy
【发布时间】:2017-07-09 18:55:04
【问题描述】:

在我的 Grails 3.2.6 应用程序中,我有 2 个类:

abstract class Base {
  static mapping = {
    tablePerHierarchy false
  }    
}

class Child extends Base {
  static mapping = {
    collection 'child'
  }
}

保存后,Child 的实例被转储到“base”集合(带有_class = Child 字段)而不是“child”。

如何让它正常工作?

更新

我将Base 定义为traitsrc/main/groovy 下:

trait Base { }

class Child implements Base { }

然后它就可以正常工作了。

【问题讨论】:

    标签: grails gorm-mongodb


    【解决方案1】:

    在您的 Child 类映射方法中,添加此

    table "child"
    

    【讨论】:

    • 被 gorm mongo 忽略,以及本案例的集合
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-19
    相关资源
    最近更新 更多