plik HBM jest:Element 'klasa' w przestrzeni nazw 'urn: nhibernate-mapping-2,2' ma nieważny element podrzędny 'własności'
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="EMSApplication.Domain.Employee, EMSApplication.Domain" table="ems_Employees" proxy="EMSApplication.Domain.IEmployee, EMSApplication.Domain">
<property name="Username">
<column name="Username" length="40" sql-type="nvarchar" not-null="true" index="Username"/>
</property>
<property name="Firstname">
<column name="Firstname" length="40" sql-type="nvarchar" not-null="true" index="Firstname"/>
</property>
</class>
</hibernate-mapping>
W Employee.cs:
namespace EMSApplication.Domain {
public class Employee : IEmployee {
private string username;
private string firstname;
public virtual string Firstname {
get {
return firstname;
}
set {
firstname = value;
}
}
public virtual string Username {
get {
return username;
}
set {
username = value;
}
}
}
}
i to jest IEmployee.cs:
namespace EMSApplication.Domain {
interface IEmployee {
string Firstname { get; set; }
string Username { get; set; }
}
}
teraz otrzymuję wyjątek:
Element "klasa" w przestrzeni nazw "urn: nhibernate-mapping-2.2" ma nieprawidłową właściwość elementu potomnego w przestrzeni nazw 'urn: nhibernate-mapping-2.2'. Lista możliwych oczekiwanych elementów: 'meta, podselekcja, pamięć podręczna, synchronizacja, komentarz, tuplizer, id, identyfikator złożonego' w przestrzeni nazw 'urn: nhibernate-mapping-2.2'.
Używam Spring.Net z NHibernate. Wywołanie pliku HBM jest:
<object id="NHibernateSessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate32">
<property name="DbProvider" ref="DbProvider"/>
<property name="MappingResources">
<list>
<value>assembly://EMSApplication/EMSApplication.Domain/EMSApplication.hbm.xml</value>
</list>
</property>
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
<entry key="dialect" value="NHibernate.Dialect.MsSql2008Dialect"/>
<entry key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
<entry key="proxyfactory.factory_class" value="NHibernate.Bytecode.DefaultProxyFactoryFactory, NHibernate"/>
<entry key="show_sql" value="true"/>
<entry key="hbm2ddl.auto" value="update"/>
<entry key="cache.use_query_cache" value="true"/>
</dictionary>
</property>
<property name="ExposeTransactionAwareSessionFactory" value="true" />
</object>
Struktura projektu jest:
Każda pomoc będzie bardzo pomocne.
Dzięki.
Rzeczywiście, brakowało elementu ID i własności w mojej klasie. Ty! – SushiGuy