C# 映射Nhibernate中不存在的列
我正在使用Oracle遗留数据库,并尝试映射与两个表的关系。不幸的是,设计数据库的公司使用了复合键 我得到了这个表(ORDERS),它的主键由3个字段组成:ordernumber(number)、version和companyC# 映射Nhibernate中不存在的列,c#,oracle,nhibernate,C#,Oracle,Nhibernate,我正在使用Oracle遗留数据库,并尝试映射与两个表的关系。不幸的是,设计数据库的公司使用了复合键 我得到了这个表(ORDERS),它的主键由3个字段组成:ordernumber(number)、version和company <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="BpSal
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="BpSalesOrders.Domain"
namespace="BpSalesOrders.Domain">
<class name="Order" table="OCSAORH" mutable="false" where="OCHAMND = 0">
<cache usage="read-only"/>
<composite-id>
<key-property name="Number" column="OCHORDN" type="String" length="10"></key-property>
<key-property name="Ver" column="OCHAMND" type="Int32"></key-property>
<key-property name="Company" column="OCHCOSC" type="String" length="5"></key-property>
</composite-id>
<property name="Reference" column="OCHOCNO" type="String" length="25"></property>
<property name="Date" column="OCHOCDT" type="Int32"></property>
<property name="Status" column="OCHSTA1" type="Char"></property>
<property name="LineOfCreditStatus" column="OCHSTA4" type="Char"></property>
<property name="WareHouse" column="OCHRESP" type="String"></property>
<set name="OrderLines" access="field.pascalcase-underscore" inverse="true" lazy="true" mutable="false">
<key>
<column name="OCLORDN" not-null="true"/>
<column name="OCLAMND" not-null="true" default="0"/>
<column name="OCLCOSC" not-null="true"/>
</key>
<one-to-many class="OrderLine" not-found ="ignore"/>
</set>
<set name="OrderReleases" access="field.pascalcase-underscore" inverse="true" lazy="true" mutable="false">
<key>
<column name="ORLORDINE" not-null="true" />
<column name="ORLSOCIETA" not-null="true"/>
</key>
<one-to-many class="OrderRelease" not-found ="ignore"/>
</set>
</class>
</hibernate-mapping>
由于表具有完全相同的键结构,因此与订单行之间存在良好的关系。
我对OrderReleases关系有问题。该表具有由OrderNumber、Company和date组成的主键。这里没有版本:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="BpSalesOrders.Domain"
namespace="BpSalesOrders.Domain">
<class name="OrderRelease" table="OCBPORDRIL" mutable="true">
<composite-id>
<key-property name="Company" column="ORLSOCIETA" type ="String" length="5"></key-property>
<key-property name="OrderNumber" column="ORLORDINE" type ="String" length="10"></key-property>
<key-property name="RequestDate" column="ORLDATARICHIESTA" type ="Int32"></key-property>
</composite-id>
<property name="Status" column="ORLSTATUS" type="Char" length="1"></property>
<property name="StatusMessage" column="ORLSEGNALAZIONE" type="String" length="90"></property>
<property name="ProcessingDate" column="ORLDATAELABORA" type ="Int32"></property>
</class>
</hibernate-mapping>
考虑到这种关系是一对多的,我想加入OrderNumber和Company上的Orders和OrderRelease表。如果我尝试这样做(如示例中所示),nHibernate会抛出一个异常,告诉我它试图映射的键由3个字段组成
有没有办法创建一个不存在的列,它不会被持久化,这样我就可以设置映射和关系了
任何帮助都将受到感谢。最终创建了一个带有假列的视图