我有两个域类如下:
Class Parent{
static hasOne = [child: Child]
static mapping= {
id(name: 'number', generator: 'assigned')
columns {
number(column: 'ST_NO')
}
}
}
Class Child{
Parent parent
static belongsTo = [parent:Parent]
static mapping = {
id(column: 'ST_NO',generator:'foreign', params: [ property: 'parent'])
columns {
parent(column: 'ST_NO', insertable: false, updateable: false)
}
}
更新子表工作正常。但是,当我尝试保存到子表时,它一直在向我抛出以下错误
IllegalArgumentException occurred while calling setter for property [Child.id (expected type = java.lang.Long)]; target = [Child : (unsaved)], property value = [1234] setter of Child.id
转储父对象时。我收到以下验证错误:
Field error in object 'Parent' on field 'child': rejected value [null].
任何人都可以建议我在这里做错了吗?