2

我需要你的帮助。

我用<Join>标签映射了我的班级并且还想添加<bag>

就像是 :

  <class name="Hilan.HilanNet.Common.Pension.ClassA,Hilan.HilanNet.Common" table="ClassA_VW">
    <cache usage="read-write"/>
    <composite-id>
      <key-property name="columnA" column="sqlColumnA"/>
      <key-many-to-one name="columnB" column="sqlColumnB" class="Hilan.HilanNet.Common.Pension.ClassB, Hilan.HilanNet.Common" />
    </composite-id>
    other properties
    <join optional="true" table="AdditionalColumns_TB" inverse="false" >
      <key>
        <column name="columnA" />
        <column name="columnB"/>
      </key>
      <property name="propertyA" />
    </join>
      here I want to add the bag
    <bag
           name="Details"
           lazy="true"
           inverse="true"
           access="nosetter.camelcase-underscore"
           table="Details_VW" cascade="all">
      <cache usage="read-only"/>
      <key>
        <column name="ColumnA" />
        <column name="ColumnB"/>
      </key>
      <property name="PrincipalId" />
    </bag>
  </class>   

但我得到一个错误 -

“命名空间‘urn:nhibernate-mapping-2.2’中的元素‘类’在命名空间中有无效的子元素‘bag’”

为什么我做不到??

谢谢 !

4

1 回答 1

2

该元素<join>需要是<class>每个元素中的最后一个元素,之后无法识别。

<class name="Hilan.HilanNet.Common.Pension.ClassA,Hilan.HilanNet.Common" table="ClassA_VW">
<cache usage="read-write"/>
<composite-id>
  <key-property name="columnA" column="sqlColumnA"/>
  <key-many-to-one name="columnB" column="sqlColumnB" class="Hilan.HilanNet.Common.Pension.ClassB, Hilan.HilanNet.Common" />
</composite-id>
<bag
       name="Details"
       lazy="true"
       inverse="true"
       access="nosetter.camelcase-underscore"
       table="Details_VW" cascade="all">
  <cache usage="read-only"/>
  <key>
    <column name="ColumnA" />
    <column name="ColumnB"/>
  </key>
  <property name="PrincipalId" />
</bag>
<join optional="true" table="AdditionalColumns_TB" inverse="false" >
  <key>
    <column name="columnA" />
    <column name="columnB"/>
  </key>
  <property name="propertyA" />
</join>
</class> 
于 2013-06-25T06:08:56.090 回答