【发布时间】:2014-08-16 01:24:47
【问题描述】:
在我使用 mongoDb 和继承的 Grails 2.3.8 应用程序中,我有这个基础域类:
class Record {
long batchID
static mapping = { tablePerHierarchy false }
}
还有这个子类:
class IndividualRecord extends Record {
String uniqueId
String firstName
String middleName
static mapping = {
collection "individualRecords"
database "twcdb"
}
static constraints = {
firstName(nullable: true)
middleName(nullable: true)
}
}
问题是我希望我的子类映射到他们自己的 mongoDb 集合,但即使使用上面的配置,我的 IndividualRecord 对象也被保存在一个名为“record”的集合中,这是基类的名称。我错过了什么?有趣的是,无论我是否从子类中删除此代码,这种行为似乎都不会改变:
static mapping = {
collection "individualRecords"
database "twcdb"
}
【问题讨论】: