0
在我的域中,我擁有多對多的關係。問題在於GORM迫使我去界定所有者實體,但我認爲任何一方都不「擁有」這種關係。刪除實體時刪除與M:N關係的關聯
class User {
String username
String password
static hasMany = [organizations: Organization]
static belongsTo = Organization
static constraints = {
}
}
class Organization {
String name;
static hasMany = [members: User]
}
在這種情況下,我顯然不能刪除的用戶是誰在一些組織(因爲組織「擁有」的關係)。我想能夠刪除這兩個實體,並刪除只需刪除關係(從user_organization表中的行)。是否有可能或者我必須自己編寫這個邏輯(如果是這樣,那麼實現這一點的最好方法是什麼)?
是的,我知道這件事。我正在尋找的正確的事情可能是這個和beforeDelete事件的結合。無論如何,我會接受你的答案,thx尋求建議。 – pseudo