Posted on 2008-06-16 15:35
G_G 閱讀(2858)
評論(1) 編輯 收藏 所屬分類:
hibernate
大家有什么好意見盡量跟我說。我盡量把這編文章弄得更適應大家開發。方便大家使用
???
此文時時更新!1.每張表除有關業務描述列外最好預留:
- ??? IsShow(true/false) 一些關鍵數據刪除采用隱藏.
- ??? version(long|int) 樂觀鎖使用 hibernate 問題_3(鎖
- ??? 預留擴展字段 (可以參考:google protobuf 等)
???
2.
關聯關系映射注意
21. 示例:父子關系(Parent Child Relationships)- ??? 添加級聯孩子對象,會生成兩條sql(
INSERT
為c
創建,
UPDATE
p
到c
的連接p)。
??? ??? ??? ??? 解決辦法:<set name="children"
inverse="true">
??? ?? ?? ?? ?? 參考:
21.2. 雙向的一對多關系(Bidirectional one-to-many)??? ?? ?? ?? ?? 解決辦法1:<set name="children" inverse="true" cascade="
all-delete-orphan">
??? ?? ?? ?? ?? 參考:
21.3. 級聯生命周期(Cascading lifecycle)??? ?? ?? ?? ?? 解決辦法2:
刪除隱藏策略
??? ?? ?? ??? <set name="children" inverse="true" where="
IsShow=boolean|int " cascade="
save-update">
??? ?? ?? ?? ? 許多數據庫沒有boolean類型可以用 整型替代 數據建立默認0可見,不可見改為1.
3一般表設計