H want to use inheritance in my application but when I run, my hbm mapping file has error. 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'."
what should I do??
StudentCourse
in theTosan.Sevrice.DataAccess.Dao
namespace
? Otherwise it will at least need a fully qualified name. And isStudentDegreeType
something that NHibernate can map? Otherwise it will need a map of it's own – starlight54