表Y中的关联指的是未映射的类:Y – C#NHibernate

我得到了例外:

"An association from the table order refers to an unmapped class: FrancosPoS.DBMapping.pastaCombo"

对于这个NHibernate映射:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="FrancosPoS" namespace="FrancosPoS.DBMapping" xmlns="urn:nhibernate-mapping-2.2">
  <class name="order" table="order" lazy="true" >
    <id name="idOrder">
      <generator class="identity" />
    </id>
    <many-to-one insert="false" update="false" lazy="false" name="idPastaI" class="FrancosPoS.DBMapping.pastaIndividual">
      <column name="idPastaI" sql-type="int(11)" not-null="false" />
    </many-to-one>
    <!--<property name="idPastaI">
      <column name="idPastaI" sql-type="int(11)" not-null="false" />
    </property>-->
    <many-to-one insert="false" update="false" lazy="false" name="pastaCombo" class="FrancosPoS.DBMapping.pastaCombo">
      <column name="idPastaC" sql-type="int(11)" not-null="false" />
    </many-to-one>
    <!--<property name="idPastaC">
      <column name="idPastaC" sql-type="int(11)" not-null="false" />
    </property>-->
    <many-to-one insert="false" update="false" lazy="false" name="idPastaF" class="FrancosPoS.DBMapping.pastaFeast">
      <column name="idPastaF" sql-type="int(11)" not-null="false" />
    </many-to-one>
    <!--<property name="idPastaF">
      <column name="idPastaF" sql-type="int(11)" not-null="false" />
    </property>-->
    <many-to-one insert="false" update="false" lazy="false" name="idSalad" class="FrancosPoS.DBMapping.salad">
      <column name="idSalad" sql-type="int(11)" not-null="false" />
    </many-to-one>
    <!--<property name="idSalad">
      <column name="idSalad" sql-type="int(11)" not-null="false" />
    </property>-->
    <many-to-one insert="false" update="false" lazy="false" name="idDrink" class="FrancosPoS.DBMapping.drink">
      <column name="idDrink" sql-type="int(11)" not-null="false" />
    </many-to-one>
    <!--<property name="idDrink">
      <column name="idDrink" sql-type="int(11)" not-null="false" />
    </property>-->
    <property name="price">
      <column name="price" sql-type="decimal(8,4)" not-null="true" />
    </property>
    <property name="cash">
      <column name="cash" sql-type="tinyint(1)" not-null="false" />
    </property>
    <property name="credit">
      <column name="credit" sql-type="tinyint(1)" not-null="false" />
    </property>
    <property name="obs">
      <column name="obs" sql-type="varchar(150)" not-null="true" />
    </property>
  </class>
</hibernate-mapping>

这是我的cs类:

namespace FrancosPoS.DBMapping {

    public partial class order {
        public order() { }
        public virtual int idOrder { get; set; }
        public virtual pastaIndividual pastaIndividual { get; set; }
        public virtual pastaCombo pastaCombo { get; set; }
        public virtual pastaFeast pastaFeast { get; set; }
        public virtual salad salad { get; set; }
        public virtual drink drink { get; set; }
        public virtual string price { get; set; }
        public virtual System.Nullable<int> cash { get; set; }
        public virtual System.Nullable<int> credit { get; set; }
        public virtual string obs { get; set; }
    }
}

pastaCombo mapping:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="FrancosPoS" namespace="FrancosPoS.DBMapping" xmlns="urn:nhibernate-mapping-2.2">
  <class name="pastaCombo" table="pasta_combo" lazy="true" >
    <id name="idPastaC">
      <generator class="identity" />
    </id>
    <property name="type">
      <column name="type" sql-type="varchar(25)" not-null="true" />
    </property>
    <property name="price">
      <column name="price" sql-type="decimal(8,4)" not-null="true" />
    </property>
    <property name="freeDrink">
      <column name="freeDrink" sql-type="smallint(5) unsigned" not-null="true" />
    </property>
    <property name="freeSalad">
      <column name="freeSalad" sql-type="smallint(5) unsigned" not-null="true" />
    </property>
  </class>
</hibernate-mapping>

pastaCombo类:

namespace FrancosPoS.DBMapping {

    public class pastaCombo {
        public pastaCombo() { }
        public virtual int idPastaC { get; set; }
        public virtual string type { get; set; }
        public virtual string price { get; set; }
        public virtual int freeDrink { get; set; }
        public virtual int freeSalad { get; set; }
    }
}

我错过了什么?

此致

PS.:属性被评论,因为我(认为我)不需要它们,因为我的类具有对象类型,而不是int ID.如果我使用它NHibernate抛出“试图通过反射设置属性类型”的错误.

编辑:包括pastaCombo映射和类.

最佳答案
所以你在某处映射了FrancosPoS.DBMapping.pastaCombo吗?是多对一,它需要引用映射的实体类型.

您对pastaCombo的映射是否实际包含在程序集中(如果使用嵌入式资源)并且程序集是否已加载到会话工厂?

转载注明原文:表Y中的关联指的是未映射的类:Y – C#NHibernate - 代码日志