我得到了例外:
"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 映射:
<?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 映射和类。