为了账号安全,请及时绑定邮箱和手机立即绑定

为什么都能实现一对多,他们之间有什么区别?

为什么都能实现一对多,他们之间有什么区别?

繁花不似锦 2023-04-10 13:09:25
<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都能实现一对多,他们之间有什么区别--></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贡献1850条经验 获得超11个赞

前者更多的是表现关联关系,后者更多的是表现从属关系 
有很多需求这种都可以实现,只是说体现不同的想法了。 
比如说一个人有很多邮箱,那么这个邮箱就是从属于这个人,那么同样,你仍然可以认为,这两种是关联关系而已。

查看完整回答
反对 回复 2023-04-12
?
一只甜甜圈

TA贡献1836条经验 获得超5个赞

使用<composite-element>标签定义component集合, 
Component是一个被包含的对象,它作为值类型被持久化,而非一个被引用的实体。“component(组件)”这一术语指的是面向对象的合成概念.

查看完整回答
反对 回复 2023-04-12
  • 2 回答
  • 0 关注
  • 88 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信