Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy can't I reference child entities with part of the parent entities composite key
    primarykey
    data
    text
    <p>I am trying to reference some child entities with part of the parents composite key not all of it, why cant I? This happens when I use the following mapping instead of that which is commented. </p> <p>I get the following error</p> <blockquote> <p>Foreign key in table VolatileEventContent must have same number of columns as referenced primary key in table LocationSearchView</p> </blockquote> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="JeanieMaster.Domain.Entities" assembly="JeanieMaster.Domain"&gt; &lt;class name="LocationSearchView" table="LocationSearchView"&gt; &lt;composite-id&gt; &lt;key-property name="LocationId" type="Int32"&gt;&lt;/key-property&gt; &lt;key-property name="ContentProviderId" type="Int32"&gt;&lt;/key-property&gt; &lt;key-property name="CategoryId" type="Int32"&gt;&lt;/key-property&gt; &lt;/composite-id&gt; &lt;property name="CompanyName" type="String" not-null="true" update="false" insert="false"/&gt; &lt;property name="Description" type="String" not-null="true" update="false" insert="false"/&gt; &lt;property name="CategoryId" type="Int32" not-null="true" update="false" insert="false"/&gt; &lt;property name="ContentProviderId" type="Int32" not-null="true" update="false" insert="false"/&gt; &lt;property name="LocationId" type="Int32" not-null="true" update="false" insert="false"/&gt; &lt;property name="Latitude" type="Double" update="false" insert="false" /&gt; &lt;property name="Longitude" type="Double" update="false" insert="false" /&gt; &lt;bag name="Events" table="VolatileEventContent" where="DeactivatedOn IS NULL" order-by="StartDate DESC" lazy="false" cascade="none"&gt; &lt;key&gt; &lt;column name="LocationId"&gt;&lt;/column&gt; &lt;column name="ContentProviderId"&gt;&lt;/column&gt; &lt;!--&lt;column name="LocationId"&gt;&lt;/column&gt; &lt;column name="ContentProviderId"&gt;&lt;/column&gt; &lt;column name="CategoryId"&gt;&lt;/column&gt;--&gt; &lt;/key&gt; &lt;one-to-many class="Event" column="VolatileEventContentId"&gt;&lt;/one-to-many&gt; &lt;/bag&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>And VolatileEventContent mapping file</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="JeanieMaster.Domain.Entities" assembly="JeanieMaster.Domain"&gt; &lt;class name="Event" table="VolatileEventContent" select-before-update="false" optimistic-lock="none"&gt; &lt;composite-id&gt; &lt;key-property name="LocationId" type="Int32"&gt;&lt;/key-property&gt; &lt;key-property name="ContentProviderId" type="Int32"&gt;&lt;/key-property&gt; &lt;/composite-id&gt; &lt;property name="Description" type="String" not-null="true" update="false" insert="false"/&gt; &lt;property name="StartDate" type="DateTime" not-null="true" update="false" insert="false" /&gt; &lt;property name="EndDate" type="DateTime" not-null="true" update="false" insert="false" /&gt; &lt;property name="CreatedOn" type="DateTime" not-null="true" update="false" insert="false" /&gt; &lt;property name="ModifiedOn" type="DateTime" not-null="false" update="false" insert="false" /&gt; &lt;many-to-one name="Location" class="Location" column="LocationId" /&gt; &lt;bag name="Artistes" table="EventArtiste" lazy="false" cascade="none"&gt; &lt;key name="VolatileEventContentId" /&gt; &lt;many-to-many class="Artiste" column="ArtisteId" &gt;&lt;/many-to-many&gt; &lt;/bag&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre>
    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.
 

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