gpt4 book ai didi

grails - GORM,为带有复合ID的joinTable的列命名

转载 作者:行者123 更新时间:2023-12-02 14:47:11 25 4
gpt4 key购买 nike

使用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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com