【发布时间】:2018-02-10 20:15:12
【问题描述】:
我有 2 个域类; A 和 B。
class A {
Long a_id
static constraints = {
}
static mapping = {
id name:'a_id'
}
}
Class B {
A a
static constraints = {
}
static mapping = {
id name:'a', generator: 'assigned'
}
}
在域B中,我想将'a'作为主键和外键(引用A.a_id)
上面的代码不起作用。请帮我。
【问题讨论】:
-
我可能是错的,但您可以尝试在您的域 B 中添加
belongsTo = [a: A]
标签: mysql hibernate grails grails-orm