【发布时间】:2014-06-02 18:20:32
【问题描述】:
我有一堂课如下
class PrefValue extends MainDomain {
String entityClass
Long entityId
....
}
我现在正在尝试将一个集合映射到两个不同的类
class TypeA extends MainDomain {
Long entityId
static hasMany = [preferences:PrefValue]
static mappedBy = [preferences: "entityId"]
...
}
class TypeB extends MainDomain {
Long entityId
static hasMany = [preferences:PrefValue]
static mappedBy = [preferences: "entityId"]
}
出现问题是因为 TypeA 和 TypeB 可以具有相同的 ID,但它们将具有不同的 entityClass 值。我将如何映射它?
【问题讨论】:
标签: grails grails-orm