无法确定类型:NHibernate.Mapping.Column(PATRF_ID)

时间:2012-10-31 20:06:02

标签: c# visual-studio-2010 nhibernate oracle10g

它给了我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)

PatRegisterReferral

的NHibernate映射
<?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; }
    }
}

PatReferralStatus

的NHibernate映射
<?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; }
    }
}

1 个答案:

答案 0 :(得分:4)

我在奋斗了2天后找到了解决方案。 ID是在基类中定义的。基类使用泛型。我在派生类的<T>中定义了错误的类型。对不起,人们花时间。傻我..