Last active
August 29, 2015 14:02
-
-
Save dario-l/10ffcc708f0c6a3a3054 to your computer and use it in GitHub Desktop.
PriceListDefinition mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
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.
Thanks. Looking forward for Your test. After 6 hours I give up (today).
PS
I added PriceList mapping.
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
CourseVariant has collection of price lists. NHibernate instantiates collection with proper subclass type (in my example TabularDefinition). TabularDefinition has reference to subclass of PriceList - ByTabularItem.
Unfortunately NHibernate instantiates ByKilometer (subclass of PriceList, too) but loads data like for ByTabularItem.
Identifiers points to correct data in database.