1
NHibernate的映射實體我有一個領域
MemID一個成員表 - 主鍵
BUSINESS_NAME
Business_Address
Business_Phone從字段在同一個表
我需要做哪些有來自性質的僱主類相同的會員表。
EmployerName
EmployerAddress
EmployerPhone
這裏是我的僱主映射
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="Employer, Entities" lazy="true" table="Members" dynamic-update="true">
<id name="MemberID" column="MemID" type="Int64">
<generator class="native" />
</id>
<many-to-one name="EmployerAddress" column="Business_Address" class="Address, Entities" lazy="proxy" />
<many-to-one name="EmployerPhone" column="Business_Phone" class="Phone, Entities" lazy="proxy"/>
<property name="EmployerName" column="Business_Name" not-null="false" />
</class>
</hibernate-mapping>
我以爲我可以映射這樣的會員類,但我得到一個「System.Collections.Generic.KeyNotFoundException:本鑑於鑰匙不在字典中。「
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="Member, Entities" lazy="true" table="Members" dynamic-update="true">
<id name="MemberID" column="MemID" type="Int64">
<generator class="native" />
</id>
<one-to-one name="EmployerInformation" class="Employer, Entities" lazy="false"/>
</class>
</hibernate-mapping>
另請注意。由於當前系統的限制,我無法將業務信息移動到另一個表。 Business_Address和Business_Phone對另一個表是FK,這就是爲什麼它們是多對一映射。
這解決了我的問題非常感謝你! – Adam 2009-04-20 02:41:23