如何通过Grails mongodb插件映射类继承层次结构?

时间:2015-05-11 15:45:09

标签: mongodb grails gorm

我们在Grails中使用MongoDB插件。

所以我找到了这个代码,一个名为Address的域对象:

public class Address extends EmbededDomain{
    static mapWith = "mongo"

    Region region;
    Zone zone;

    static mapping = {
        id generator: 'identity'
        region reference:true
        zone reference:true
    }
}

EmbededDomainsrc/groovy

中的一个班级
class EmbeddedDomain {
    public EmbeddedDomain() {
        this.dateCreated = new Date()
        this.lastUpdated = new Date()
    }
}

然后我有Organization域关系组织有地址:

class Organization {
    static mapWith = "mongo"

    Address address

    static mapping = {
        id generator: 'identity'
    }
}

区域reference:true是什么意思?

当我在MongoDB控制台中输入命令Organization时保存show Collections后,我没有看到名为Address的集合?相反,我看到名称为EmbededDomain的集合,其中包含所有地址,为什么会发生这种情况EmbededDomain只是一个Groovy类。

0 个答案:

没有答案
相关问题