<class name="Customer,DomainModel" table="Customer"> <id name="CustomerId" column="CustomerId" type="Int32" unsaved-value="0"> <generator class="native"></generator> </id> <property name="Firstname" column="Firstname" type="string" length="50" not-null="false"></property> <property name="Lastname" column="Lastname" type="string" length="50" not-null="false"></property> <bag name="Orders" table="[Order]" generic="true" inverse ="false" cascade ="All" > <key column="Customer"/> <span style="color: #ff0000;"> <!--這里面 one-to-many 和 composite-element都能實現(xiàn)一對多,他們之間有什么區(qū)別--></span> <one-to-many class="DomainModel.Entities.Order,DomainModel" /> <!--composite-element class="DomainModel.Entities.Order,DomainModel"> <parent name="Customer"/> <property name="OrderId" column="OrderId" type="Int32"/> <property name="OrderDate" column ="OrderDate" type="DateTime" not-null="false"/> </composite-element--> </bag> </class>
2 回答

慕蓋茨4494581
TA貢獻(xiàn)1850條經(jīng)驗 獲得超11個贊
前者更多的是表現(xiàn)關(guān)聯(lián)關(guān)系,后者更多的是表現(xiàn)從屬關(guān)系
有很多需求這種都可以實現(xiàn),只是說體現(xiàn)不同的想法了。
比如說一個人有很多郵箱,那么這個郵箱就是從屬于這個人,那么同樣,你仍然可以認(rèn)為,這兩種是關(guān)聯(lián)關(guān)系而已。

一只甜甜圈
TA貢獻(xiàn)1836條經(jīng)驗 獲得超5個贊
使用<composite-element>標(biāo)簽定義component集合,
Component是一個被包含的對象,它作為值類型被持久化,而非一個被引用的實體?!癱omponent(組件)”這一術(shù)語指的是面向?qū)ο蟮暮铣筛拍?
添加回答
舉報
0/150
提交
取消