简体   繁体   English

映射hbm文件时出现错误“元素'class'在名称空间中具有无效的子元素'set'”

[英]error “The element 'class' in has invalid child element 'set' in namespace ” when mapping hbm file

H want to use inheritance in my application but when I run, my hbm mapping file has error. H想在我的应用程序中使用继承,但是当我运行时,我的hbm映射文件有错误。 my code is here 我的代码在这里

 public class StudentDao
    {

        public virtual int Id { get; set; }
        public virtual string FirstName { get; set; }
        public virtual string LastName { get; set; }
        public virtual StudentDegreeType Degree { get; set; }
        public virtual string Field { get; set; }
        public virtual IEnumerable<StudentCourse> StudentCourses { get; set; }

my mapping file is : 我的映射文件是:

    <?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="Tosan.Sevrice.DataAccess" namespace="Tosan.Sevrice.DataAccess.Dao" xmlns="urn:nhibernate-mapping-2.2">
  <class name="StudentDao" table="STUDENTT" lazy="true" >
    <id name="Id" column="ID" >
      <generator class="increment"> </generator>
    </id>
    <discriminator column="Degree"/>

    <property name="FirstName" column="FIRSTNAME" />
    <property name="LastName" column="LASTNAME" />
    <!--<property name="Degree" column="DEGREE" />-->
    <property name="Field" column="FIELD" />

    <subclass name="MasterStudent" discriminator-value="1">
         <property name="َArticle"  />
    </subclass>
    <subclass name="BachelorStudent" discriminator-value="2">

    </subclass>

    <set name="StudentCourses" table="StudentCourse" inverse="true" cascade="all,delete-orphan">
      <key column="ID"/>
      <one-to-many class="StudentCourse"/>
    </set>

  </class>
</hibernate-mapping>

I use a relationship tag in my file mapping 'set' 我在文件映射“设置”中使用了关系标签

my child classes is : 我的孩子班是:

public class BachelorStudent : StudentDao
    {
    }
}

and the next child class : 下一个孩子班:

public class MasterStudent : StudentDao
    {
        public virtual bool Article { get; set; }
    }
}

after I run this the error bellow come out : 在我运行此错误波纹管出来后:

"The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'set' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'subclass, loader, sql-insert, sql-update, sql-delete, filter, resultset, query, sql-query' in namespace 'urn:nhibernate-mapping-2.2'." “名称空间'urn:nhibernate-mapping-2.2'中的元素'class'在名称空间'urn:nhibernate-mapping-2.2'中具有无效的子元素'set'。可能的元素列表:'子类,加载器,sql-insert ,命名空间“ urn:nhibernate-mapping-2.2”中的sql-update,sql-delete,过滤器,结果集,查询,sql-query”。

what should I do?? 我该怎么办??

set elements needs to be defined before subclass elements. set元素需要在子类元素之前定义。 ie: 即:

<set name="StudentCourses" table="StudentCourse" inverse="true" cascade="all,delete-orphan">
  <key column="ID"/>
  <one-to-many class="StudentCourse"/>
</set>

<subclass name="MasterStudent" discriminator-value="1">
     <property name="َArticle"  />
</subclass>
<subclass name="BachelorStudent" discriminator-value="2">

</subclass>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 命名空间&#39;urn:nhibernate-mapping-2.2&#39;中的元素&#39;class&#39;具有无效的子元素&#39;property&#39; - The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'property' 命名空间B中的元素A在命名空间D中具有无效的子元素C. - The element A in namespace B has invalid child element C in namespace D 命名空间“...”中的元素“...”具有无效的子元素,即使架构中存在子元素 - The element '...' in namespace '...' has invalid child element, even though child element exists in schema 流利:名称空间中的子元素“多对一”无效 - Fluent: has invalid child element 'many-to-one' in namespace NHibernate映射错误-无效的子元素“多对一” - NHibernate mapping error - invalid child element 'many-to-one' 如何在Microsoft.CppBuild.targets中抑制类型为“名称空间X中的元素X具有无效的子元素……”的警告 - How to suppress warnings of type “The Element X in namespace X has invalid child element …” within Microsoft.CppBuild.targets 子元素上的XML命名空间 - XML namespace on child element XML元素具有无效的子元素“ X”,预期为“ X” - XML element has invalid child element 'X', expected 'X' 元素&#39;entityFramework&#39;具有无效的子元素Entity Framework - The element 'entityFramework' has invalid child element Entity Framework XDocument.Validate返回的Element具有无效的子元素 - XDocument.Validate returning The Element has invalid child element
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM