2
我有4類,事件,問題,請求和另一個是附件。屬於多個域
每個域的樣子.........
Class Incidents
{
// other fields
static hasOne = [attachment: Attachment]
static constraints = [attachment nullable:true]
}
Class Problems
{
// other fields
static hasOne = [attachment: Attachment]
static constraints = [attachment nullable:true]
}
Class Requests
{
// other fields
static hasOne = [attachment: Attachment]
static constraints = [attachment nullable:true]
}
Class Attachment
{
// other fields
static belongsTo= [
incident: Incidents,
problem: Problems,
requests: Requests
]
static constraints = {
incident nullable: true
problem nullable: true
requests nullable: true
}
當我節省事件的對象
,它會引發像列「PROBLEM_ID」不能爲空例外。 該怎麼辦?
去除類事件,問題,請hasOne和替換它,如果我刪除的關係,然後將它讓我刪除級聯? – sanghavi7
級聯刪除嘗試添加級聯映射。我已經更新了答案。 –
是的,男人它很好地工作,thanx – sanghavi7