使用Grails 1.3.7,我必须处理旧版数据库。我在连接表中有一个域对象“Cake”,该对象具有其自己的嵌入式“成分”集合。
成分
class Ingredient {
String name
IngredientCategory category
mapping {
table "foo_ingredient"
version false
id composite:['name', 'category']
columns {
word column:"the_name"
category column:"lol_category_id"
}
}
}
Cake.groovy
class Cake {
String name
static hasMany = [ ingredients : Ingredient ]
static mapping = {
table "foo_cake"
version false
columns {
id column:"id"
name column:"the_name"
}
ingredients joinTable: [
name : "foo_cake_ingredient",
key : "cake_id"
]
}
}
问题是,Grails希望表“foo_cake_ingredient”具有两列“ingredient_name”和“ingredient_category_id”。我想手动指定那些列名,而不要让Grails(错误地)猜那些。我不知道该怎么做。
最佳答案
关于grails - GORM,为带有复合ID的joinTable的列命名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6067498/