Nhibernate:从包中的孩子返回的多个相同记录

时间:2011-05-13 14:42:02

标签: nhibernate many-to-many bag

当使用行李从子表中退回物品时,我会收到行李中正确数量的物品,但所有行都相同。

SearchPerson实体的映射

 <?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Nortonrose.DataAccess" namespace="Nortonrose.DataAccess.Mappings">
  <class name="Nortonrose.DataAccess.SearchEntities.PersonSearchEntity" table="nr_rx_person" lazy="true">

        <id name="RxId">
          <column name="rx_id"/>
          <generator class="native" />
        </id>
        <property name="Locale">
          <column name="locale"/>
        </property>
        <property name="Firstname">
          <column name="first_name"/>
        </property>
        <property name="Lastname">
          <column name="last_name"/>
        </property>
        <property name="URL">
          <column name="rx_id"/>
        </property>
        <property name="Email">
          <column name="email"/>
        </property>
        <property name="Phone">
          <column name="DDI"/>
        </property>
        <property name="SearchMapping">
          <column name="search_mapping_position"/>
        </property>
                <property name="Image">
                    <column name="image"/>
                </property>
                <property name="Position">
                    <column name="job_title"/>
                </property>
        <bag name="Expertises" >
            <key column="rx_id"/>

            <many-to-many class="Nortonrose.DataAccess.SearchEntities.ExpertiseEntity"/>
            <!--<property name="ExpertiseID"/>-->
        </bag>



        <bag name="Locations" >
            <key column="rx_id"/>
            <one-to-many class="Nortonrose.DataAccess.SearchEntities.LocationEntity"/>
            <!--<property name="ExpertiseID"/>-->
        </bag>
    </class>

包中的专业知识实体

    <?xml version="1.0" encoding="utf-8" ?>

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Nortonrose.DataAccess" namespace="Nortonrose.DataAccess.Mappings">

  <class name="Nortonrose.DataAccess.SearchEntities.ExpertiseEntity" table="v_ExpertiseTitle" lazy="true">

        <id name="RxId">

          <column name="rx_id"/>


          <generator class="native" />

        </id>

        <property name="ExpertiseTitle">

            <column name="title"/>

        </property>

    </class>



</hibernate-mapping>

专业知识表具有用户ID,专业知识ID,并映射到专业知识标题。这一切都在一个视图中完成。

由于 詹姆斯

0 个答案:

没有答案