Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibernate Mapping Entity from Fields in same table
    primarykey
    data
    text
    <p>I have a Member Table with fields <br>MemID - Primary Key <br>Business_Name <br>Business_Address <br>Business_Phone</p> <p>I need to make an Employer Class which has properties that come from the same Members Table. <br>EmployerName <br>EmployerAddress <br>EmployerPhone</p> <p>Here is my Employer Mapping</p> <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true"&gt; &lt;class name="Employer, Entities" lazy="true" table="Members" dynamic-update="true"&gt; &lt;id name="MemberID" column="MemID" type="Int64"&gt; &lt;generator class="native" /&gt; &lt;/id&gt; &lt;many-to-one name="EmployerAddress" column="Business_Address" class="Address, Entities" lazy="proxy" /&gt; &lt;many-to-one name="EmployerPhone" column="Business_Phone" class="Phone, Entities" lazy="proxy"/&gt; &lt;property name="EmployerName" column="Business_Name" not-null="false" /&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>I thought that I could map the Members class like this but I get a "System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary."</p> <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true"&gt; &lt;class name="Member, Entities" lazy="true" table="Members" dynamic-update="true"&gt; &lt;id name="MemberID" column="MemID" type="Int64"&gt; &lt;generator class="native" /&gt; &lt;/id&gt; &lt;one-to-one name="EmployerInformation" class="Employer, Entities" lazy="false"/&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>Also please note. I can't move the Business Information to another table due to constraints on the current system. Business_Address and Business_Phone are FK to another table that is why they are many-to-one mappings.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload