我想引用一些子實體與部分父母組合鍵不是全部,爲什麼我不能?當我使用下面的映射而不是被評論的時候,會發生這種情況。爲什麼我不能引用子實體與部分父實體組合鍵
我收到以下錯誤
表外鍵 VolatileEventContent必須有相同的 列數在表中引用 主鍵 LocationSearchView
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="JeanieMaster.Domain.Entities" assembly="JeanieMaster.Domain">
<class name="LocationSearchView" table="LocationSearchView">
<composite-id>
<key-property name="LocationId" type="Int32"></key-property>
<key-property name="ContentProviderId" type="Int32"></key-property>
<key-property name="CategoryId" type="Int32"></key-property>
</composite-id>
<property name="CompanyName" type="String" not-null="true" update="false" insert="false"/>
<property name="Description" type="String" not-null="true" update="false" insert="false"/>
<property name="CategoryId" type="Int32" not-null="true" update="false" insert="false"/>
<property name="ContentProviderId" type="Int32" not-null="true" update="false" insert="false"/>
<property name="LocationId" type="Int32" not-null="true" update="false" insert="false"/>
<property name="Latitude" type="Double" update="false" insert="false" />
<property name="Longitude" type="Double" update="false" insert="false" />
<bag name="Events" table="VolatileEventContent" where="DeactivatedOn IS NULL" order-by="StartDate DESC" lazy="false" cascade="none">
<key>
<column name="LocationId"></column>
<column name="ContentProviderId"></column>
<!--<column name="LocationId"></column>
<column name="ContentProviderId"></column>
<column name="CategoryId"></column>-->
</key>
<one-to-many class="Event" column="VolatileEventContentId"></one-to-many>
</bag>
</class>
</hibernate-mapping>
而且VolatileEventContent映射文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="JeanieMaster.Domain.Entities" assembly="JeanieMaster.Domain">
<class name="Event" table="VolatileEventContent" select-before-update="false" optimistic-lock="none">
<composite-id>
<key-property name="LocationId" type="Int32"></key-property>
<key-property name="ContentProviderId" type="Int32"></key-property>
</composite-id>
<property name="Description" type="String" not-null="true" update="false" insert="false"/>
<property name="StartDate" type="DateTime" not-null="true" update="false" insert="false" />
<property name="EndDate" type="DateTime" not-null="true" update="false" insert="false" />
<property name="CreatedOn" type="DateTime" not-null="true" update="false" insert="false" />
<property name="ModifiedOn" type="DateTime" not-null="false" update="false" insert="false" />
<many-to-one name="Location" class="Location" column="LocationId" />
<bag name="Artistes" table="EventArtiste" lazy="false" cascade="none">
<key name="VolatileEventContentId" />
<many-to-many class="Artiste" column="ArtisteId" ></many-to-many>
</bag>
</class>
</hibernate-mapping>
你可以發佈'VolatileEventContent'的映射嗎? – 2010-02-23 13:42:46
添加了附加映射 – 2010-02-23 13:53:18