Skip to content

Instantly share code, notes, and snippets.

@dario-l
Last active August 29, 2015 14:02
Show Gist options
  • Save dario-l/10ffcc708f0c6a3a3054 to your computer and use it in GitHub Desktop.
Save dario-l/10ffcc708f0c6a3a3054 to your computer and use it in GitHub Desktop.
PriceListDefinition mapping
<class xmlns="urn:nhibernate-mapping-2.2" lazy="true" schema="timetables" name="PriceList" table="PriceLists">
<id name="ID/>
<discriminator type="String">
<column name="discriminator" />
</discriminator>
<version name="Version">
<column name="Version" />
</version>
<property name="Number" type="System.Int32">
<column name="Number" not-null="true" />
</property>
<subclass name="ByKilometer" />
<subclass name="ByTabularItem" />
</class>
<class xmlns="urn:nhibernate-mapping-2.2" lazy="true" schema="timetables" name="PriceListDefinition" table="PriceListDefinitions">
<id name="ID"/>
<discriminator type="String">
<column name="discriminator" />
</discriminator>
<property name="Priority" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Priority" not-null="true" />
</property>
<many-to-one cascade="save-update" class="CourseVariant" foreign-key="FK_PriceListDefinitions_CourseVariant" lazy="proxy" name="CourseVariant">
<column name="CourseVariant_Id" index="IX_PriceListDefinitions_CourseVariant" not-null="false" />
</many-to-one>
<subclass name="KilometerDefinition">
<many-to-one access="field.camelcase-underscore" cascade="save-update" class="ByKilometer" foreign-key="FK_KilometerDefinitions_PriceList" lazy="no-proxy" name="PriceList">
<column name="PriceList_Id" index="IX_KilometerDefinitions_PriceList" not-null="false" />
</many-to-one>
</subclass>
<subclass name="TabularDefinition">
<many-to-one access="field.camelcase-underscore" cascade="save-update" class="ByTabularItem" foreign-key="FK_TabularDefinitions_PriceList" lazy="no-proxy" name="PriceList">
<column name="PriceList_Id" index="IX_TabularDefinitions_PriceList" not-null="false" />
</many-to-one>
</subclass>
</class>
@tchrikch
Copy link

Seems (or I assume) that the PriceList is not mapped directly to the database as a table (although subclasses are) so nhibernate needs to "guess the type" from the first mapping available which is ByKilometer in this case. You can verify if switching the order of KilometerDefinition and TabularDefinition suddenly gives the expected subclass. But i will try to compile it and test it tomorrow.

@dario-l
Copy link
Author

dario-l commented Jun 13, 2014

Thanks. Looking forward for Your test. After 6 hours I give up (today).

PS
I added PriceList mapping.

@dario-l
Copy link
Author

dario-l commented Jun 16, 2014

I gave up. Replaced reference to PriceListId property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment