2010-01-06 4 views
8

나는 몇 시간 동안이 NHibernate 문제로 고심하고있다. 나는 NHibernate 문서뿐만 아니라 웹에서 광범위하게 연구했다. 나는이 문제에 대해 아무런 의미가 없다. 나는 NHibernate에 비교적 새로운 것이고 그것을 좋아한다. 그렇다면, 그것은 나를 미치게합니다.C#/NHibernate : 연결 참조 매핑되지 않은 클래스

웹 사이트 용 "설문 조사"모듈을 작성 중입니다. 나는 여러 클래스 (Poll, PollVote 및 PollAnswer)를 가지고 있습니다. 주된 설문 조사 인 Poll이 문제의 원인입니다. 이이 클래스는 모습 같은 :

public class Poll 
    { 
     public virtual int Id { get; set; } 
     public virtual Site Site { get; set; } 
     public virtual string Question { get; set; } 
     public virtual bool Locked { get; set; } 
     public virtual bool Enabled { get; set; } 
     public virtual ICollection<PollAnswer> AnswersSet { get; set; } 
     public virtual ICollection<PollVote> VotesSet { get; set; } 
    } 

그리고이 같은 매핑 모습입니다 :

Association references unmapped class: Folke.Code.Domain.PollAnswer Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: NHibernate.MappingException: Association references unmapped class: Folke.Code.Domain.PollAnswer

난 정말 이것을 이해하려면이 나에게 오류를 반환

<?xml version="1.0" encoding="utf-8" ?> 
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
        assembly="Folke" 
        namespace="Folke.Code.Domain"> 
    <class name="Poll"> 
    <id name="Id"> 
     <generator class="native"></generator> 
    </id> 
    <property name="Site"/> 
    <property name="Question"/> 
    <property name="Locked"/> 
    <property name="Enabled"/> 
    <set name="AnswersSet" lazy="true"> 
     <key column="PollId"/> 
     <one-to-many class="PollAnswer"/> 
    </set> 
    <set name="VotesSet" lazy="true"> 
     <key column="PollId"/> 
     <one-to-many class="PollVote"/> 
    </set> 
    </class> 
</hibernate-mapping> 

, 그리고 더 잘 NHibernate의 내부 작업을 이해합니다.

답변

8

Poll과 PollAnswer 사이의 일대 다 관계를 정의하고 있으므로, hbm.xml 파일에 PollAnswer에 대한 섹션이 필요합니다. . 당신은 PollVote 하나뿐이 필요합니다.

+13

또한 포함 리소스로 설정 빌드 작업, 빌드 작업을 위해 임베디드 리소스로 설정됩니다. – bitsprint

12

을 당신>은 .hbm.xml 파일을 이동하는 특성을 필요>를 hbm.xml 파일 속성에서

관련 문제