1

它给了我NHibernate的上述错误。我正在使用 VS 2010、C#、Oracle 10g。我尝试搜索谷歌,stackoverflow,但没有运气。以下文件给了我错误。

例外Could not determine type for: .....PatRegisterReferral, ...., Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, for columns: NHibernate.Mapping.Column(PATRF_ID)

NHibernate 映射为PatRegisterReferral

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="...." assembly="...">
  <class name=".......PatRegisterReferral, ....." table="......">
    <id name="Id" column="PATRF_ID" unsaved-value="0">
      <generator class="sequence" >
       <param name="sequence">PATRF_SEQ</param>
      </generator>
    </id>    
   <timestamp name="ModifyDate" column="MODIFY_DATE" generated="always" />
   <property name="CreateDate" column="CREATE_DATE" update="false" />
   <property name="CreateBy" column="CREATE_BY" update="false" />
   <property name="ModifyBy" column="MODIFY_BY" update="false" />
   <property name="EffDate" column="EFF_DATE" />
   <property name="ExpDate" column="EXP_DATE" />
   <many-to-one name="PatReferralStatus" class="PatReferralStatus">
    <column name="PATRS_CODE"></column>
   </many-to-one>      
 </class>
</hibernate-mapping>

PatRegisterReferral班级:

 public class PatRegisterReferral
 {

    private PatReferralStatus _patReferralStatus = null;

    public override int GetHashCode()
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append(this.GetType().FullName);
        sb.Append(EffDate);
        sb.Append(ExpDate);            
        if (PatReferralStatus.Id != null) sb.Append(PatReferralStatus.Id);            
        return sb.ToString().GetHashCode();
    }

    public virtual DateTime EffDate { get; set; }
    public virtual DateTime? ExpDate { get; set; }
    public virtual string CreateBy { get; set; }
    public virtual DateTime CreateDate { get; set; }
    public virtual string ModifyBy { get; set; }
    public virtual DateTime ModifyDate { get; set; }

    public virtual PatReferralStatus PatReferralStatus
    {
        get { return _patReferralStatus; }
        set { _patReferralStatus = value; }
    }
}

NHibernate 映射为PatReferralStatus

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="...." assembly="....">
 <class name="...., ...." table="...." mutable="false" batch-size="10" lazy="false">
  <id name="Id" column="PATRS_CODE" unsaved-value="0">
   <generator class="assigned"></generator>
  </id>
  <timestamp name="ModifyDate" column="MODIFY_DATE" generated="always" />
  <property name="Descrip" column="DESCRIP" />
  <property name="DescripFr" column="DESCRIP_FR" />
  <property name="EffDate" column="EFF_DATE" />
  <property name="ExpDate" column="EXP_DATE" />
  <property name="CreateBy" column="CREATE_BY" />
  <property name="CreateDate" column="CREATE_DATE" />
  <property name="ModifyBy" column="MODIFY_BY" />
  <bag name ="PatRegisterReferrals" lazy="true" cascade="all-delete-orphan" inverse="true">
   <key column="PATRS_CODE"></key>
   <one-to-many class="PatRegisterReferral"></one-to-many>      
  </bag>    
 </class>
</hibernate-mapping>

类定义PatReferralStatus

public class PatReferralStatus
{
    private IList<PatRegisterReferral> _patRegisterReferrals = null;

    public override int GetHashCode()
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append(this.GetType().FullName);
        sb.Append(Descrip);
        sb.Append(DescripFr);
        sb.Append(EffDate);
        sb.Append(ExpDate);
        return sb.ToString().GetHashCode();
    }

    public virtual string Descrip { get; set; }
    public virtual string DescripFr { get; set; }
    public virtual DateTime EffDate { get; set; }
    public virtual DateTime? ExpDate { get; set; }
    public virtual string CreateBy { get; set; }
    public virtual DateTime CreateDate { get; set; }
    public virtual string ModifyBy { get; set; }
    public virtual DateTime ModifyDate { get; set; }

    public virtual IList<PatRegisterReferral> PatRegisterReferrals
    {
        get { return _patRegisterReferrals; }
        set { _patRegisterReferrals = value; }
    }
}
4

1 回答 1

4

经过两天的努力,我找到了解决方案。ID 是在基类中定义的。基类使用泛型。<T>我在派生类中定义了错误的类型。很抱歉人们耽误了你的时间。傻我..

于 2012-11-02T17:06:52.763 回答