2010-01-27 2 views
3

:협회 참조 매핑되지 않은 클래스 예외

public class Employee 
{ 
    public virtual int ObjectID { get; set; } 
    public virtual string LastName { get; set; } 
    public virtual string FirstName { get; set; } 
    public virtual string Title { get; set; } 
    public virtual string TitleOfCourtesy { get; set; } 
    public virtual DateTime HireDate { get; set; } 
    public virtual DateTime BirthDate { get; set; } 
    public virtual string Address { get; set; } 
    public virtual string City { get; set; } 
    public virtual string Region { get; set; } 
    public virtual string PostalCode { get; set; } 
    public virtual string Country { get; set; } 
    public virtual string HomePhone { get; set; } 
    public virtual string Extension { get; set; } 
    public virtual byte[] Photo { get; set; } 
    public virtual string Notes { get; set; } 
    public virtual string PhotoPath { get; set; } 

    public virtual ISet<Employee> Subordinates { get; set; } 
    public virtual Employee ReportsTo { get; set; } 
} 

매핑 :

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
auto-import="true" namespace="NHibernateTests.Data" assembly="NHibernateTests"> 
    <class name="Employee" lazy="false" entity-name="Employees"> 
    <id name="ObjectID" access="property" column="EmployeeID" > 
     <generator class="native" /> 
    </id> 
    <property name="LastName" access="property" column="LastName"/> 
    <property name="FirstName" access="property" column="FirstName"/> 
    <property name="Title" access="property" column="Title"/> 
    <property name="TitleOfCourtesy" access="property" column="TitleOfCourtesy"/> 
    <property name="BirthDate" access="property" column="BirthDate"/> 
    <property name="HireDate" access="property" column="HireDate"/> 
    <property name="Address" access="property" column="Address"/> 
    <property name="City" access="property" column="City"/> 
    <property name="Region" access="property" column="Region"/> 
    <property name="PostalCode" access="property" column="PostalCode"/> 
    <property name="Country" access="property" column="Country"/> 
    <property name="HomePhone" access="property" column="HomePhone"/> 
    <property name="Extension" access="property" column="Extension"/> 
    <property name="Photo" access="property" column="Photo"/> 
    <property name="Notes" access="property" column="Country"/> 
    <property name="PhotoPath" access="property" column="PhotoPath"/> 

    <set name="Subordinates" table="Employees" access="property" lazy="false" inverse="true"> 
     <key column="ReportsTo"/> 
     <one-to-many class="Employee" /> 
    </set> 

    <many-to-one name="ReportsTo" column="ReportsTo" access="property" not-null="false"/> 
    </class> 
</hibernate-mapping> 

내가 "가 계속 협회 참조 매핑되지 않은 클래스 : NHibernateTests.Data합니다. Employee "MappingException입니다. 자체 연결 부분 (Subordinates 및 ReportsTo)이 주석 처리 된 상태에서 올바르게 작동합니다.

매핑에 어떤 문제가 있습니까?

답변

5

바보 오류 : 엔티티 이름 대신 테이블 속성을 사용했다.

8

때때로 HBM 파일의 속성을 설정하지 않을 때 위의 오류가 발생합니다. 그래서, 당신의 hbm 파일 속성에 가서 내가 NHibernate에 환경 WPF이 시나리오를 테스트 한

BuildAction = EmbeddedResource 

를 선택합니다.

0

머리가 긁히는 결과가 발생하는 것과 같은 오류가 발생했습니다. 그래서 다른 누군가가 같은 문제를 가지고있는 경우에 대비하여 솔루션을 추가하고 싶습니다 ...

내가 관계에서 참조하고있는 엔터티는 바보 복사/붙여 넣기의 결과 인 abstract입니다. 일단 내가 abstract을 가져 가면 잘 실행됩니다.

관련 문제