GORM中的關聯

2021-05-25 03:04:45 字數 804 閱讀 1064

gorm

中的關聯

1.one-to-one

:使用belongsto

來設定

class face 

class nose 

2.

one-to-many

:在grails

中定義這樣的關聯可以使用

hasmany

class author

class book

預設的級聯行為是級聯儲存和更新,但不刪除,除非belongsto被指定:

class author

class book

3.

many-to-many

:通過在關聯雙方定義

hasmany

,並在關聯擁有方定義

belongsto

class book

class author 

4.集合型別基礎

:gorm

將使用乙個鏈結表,來對映上面的關聯。你可以使用jointable引數來改變各式各樣的連線表對映:

class person

}

gorm中的刪除

刪除一條記錄時,刪除物件需要指定主鍵,否則會觸發 批量 delete,例如 db.debug where id 6 delete new user delete from users where id 6 db.debug delete user 5 delete from users where ...

gorm 一對多關聯關係

乙個活動表的關聯多個活動條件 乙個活動條件關聯多個活動配置 資料結構 首先要找到對應的視角,我這個就活動向下取 1.在條件中新增與活動的關聯 activityid 同理conditionid activityid stringgorm column activity id json activity...

gorm增刪查改json gorm 關聯查詢請教

有如下兩張表 type activity record struct select activity records.id,activity records.activity config id find list 列印的 sql 語句 2020 07 06 09 54 57 1.00ms sele...