0

我需要 Hibernate,因为我使用的一些插件依赖于它。所以我同时使用 MongoDB 和 Hibernate 插件。

有没有办法让 MongoDB 处理插件域类而不直接编辑域类文件?最干净的方法是什么?

任何建议都是最受欢迎的。提前致谢。

4

1 回答 1

1

当然有办法

你应该添加

static mapWith = "mongo" 

例如在您的域类中

class Example {
  static mapWith = "mongo"
  ObjectId id
  String someProperty
}

最好的解决方案是制作包含一些属性的抽象类

abstract class BaseDomain implements Serializable {
    static mapWith = "mongo"
    ObjectId id
}

然后在您的域类上扩展它

class Example extends BaseDomain{
  String someProperty
}
于 2012-05-15T09:53:34.617 回答