nHibernate映射文件

时间:2010-05-17 16:33:10

标签: nhibernate-mapping

                

<property name="NetworkRunId" column="Network_Run_Id" />
<property name="StudyKey" column="Study_Key" insert="false" update="false" />
<property name="AnnualizationFactor" column="Annualization_Factor" />
<property name="CreateDate" column="Create_Date" />
<property name="ModifyDate" column="Modify_Date" />

<many-to-one name="StudyInfo" class="Study" lazy="false" cascade="save-update">
  <column name="Study_Key" />
</many-to-one>

                                                                          

<many-to-one name="MemberInfo"
             class="BusinessDataEntities.Domain.NetworkAdministration.VHAMemberCompany, BusinessDataEntities"
             lazy="false">
  <column name="Member_ID" />
</many-to-one>

<many-to-one name="NetworkRunStudyXrefInfo"
             class="BusinessDataEntities.Domain.NetworkAdministration.NetworkRunStudyXref, BusinessDataEntities"
             lazy="false">
  <column name="Network_Run_Id" />
</many-to-one>

<join table="[HCO_Spend_Network_Run_Study]">
  <key column="HCO_Spend_Id" />
  <property name="NetworkRunId" column="Network_Run_Id" insert="false" update="false"/>
</join>

问题            

第一个表中不存在网络运行ID 但我有一个联网,将Network_Run_Id作为属性如何解决此问题

1 个答案:

答案 0 :(得分:0)

如果列 NetworkRunId 是您的主键,则将其与<id>元素一起映射。

<class ...>
    <id name="NetworkRunId" column="Network_Run_Id">
        <generator class="identity"/>
    </id>
</class>

对于生成器类,请选择最适合您的底层数据库引擎的那个。

编辑#1

为了映射many-to-many关联,您可能需要关注有关Collection Mapping的文档。也许向下滚动到 6.3 会回答你的问题。