Grails GORM继承列定义映射
你好evreyone 我有两个表(A和B,扩展了A)。A和B是具有指定Id的现有表。Id(PK)是A和B中的字符串 使用GORM,如果A和B之间的公共列不是默认列(带有Grails的列“id”),我就无法映射这两个表 例如:Grails GORM继承列定义映射,grails,inheritance,gorm,Grails,Inheritance,Gorm,你好evreyone 我有两个表(A和B,扩展了A)。A和B是具有指定Id的现有表。Id(PK)是A和B中的字符串 使用GORM,如果A和B之间的公共列不是默认列(带有Grails的列“id”),我就无法映射这两个表 例如: class A { String acc; static mapping = { datasource 'xx' table "A" version false tablePerHierarch
class A {
String acc;
static mapping = {
datasource 'xx'
table "A"
version false
tablePerHierarchy false
id generator: 'assigned', name: 'acc'
cache 'read-only'
}
class B extends A {
String acc;
static mapping = {
datasource 'xx'
table "B"
version false
id generator: 'assigned', name: 'acc'
cache 'read-only'
}
请问前面的映射有什么问题
1/Grails在B表中生成一个我不想要的Id列。
2/我无法加载B对象(因为HQL将列acc(表a)链接到列id(表B中的新列)
有什么想法吗?在id映射中添加一个
列
参数:
id generator: 'assigned', name: 'acc', column: 'acc'
这很有效,安德鲁。谢谢你的快速回答!