[英]grails, relations and cascade delete
我有以下域類:
class Patient {
...
}
class Receipt{
@NotNull
static belongsTo = [patient:Patient]
...
}
如果我嘗試刪除Patient
實例(在創建Receipt
實例之后),則我有一個MySQLIntegrityConstraintViolationException
。 請注意,患者可以有零對多收據。
要完成父子關系,請在父域類中創建一個具有許多部分的部分:
class Patient {
static hasMany = [receipts: Receipt]
...
}
class Receipt{
@NotNull
static belongsTo = [patient:Patient]
...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.