簡體   English   中英

grails,關系和級聯刪除

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM