I am using AddAssembly(assembly) to add an assembly to NHibernate. The assembly contains objects that form the inheritance hierarchy as follow:
Item<--SellableItem<--PhysicalItem<--Asset
where Item is the base class.
I am not setting the skipOrder parameter so I expect Hibernate to order the mapping files according to the inheritance hierarchy.
The problem I am running into is that sometimes Hibernate doesn't seem to order the mapping files the way it is in the inheritance hierarchy and I get the following mapping exception:
Could not compile the mapping document: Platform.Asset.hbm.xml ---> NHibernate.MappingException: Could not compile the mapping document: Platform.Asset.hbm.xml ---> NHibernate.MappingException: Cannot extend unmapped class: Platform.PhysicalItem,A first chance exception of type 'NHibernate.MappingException' occurred in NHibernate.dll.
This seems to have something to do with the order of the mapping files read from the assembly resource because it happens if the order of the mapping file read from assembly by AddAssembly() is:
Asset
Sellable
PhysicalItem
Item
Does anyone have any idea what causes this and if there is a way to work around it?
Hibernate version:
1.2.0.beta3
Mapping documents:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Platform"
assembly="Platform"
default-cascade="save-update">
<joined-subclass name="Patform.Asset"
extends="Platform.PhysicalItem, Platform"
table="ASSET">
<key column="UNIQUE_ID" />
</joined-subclass>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Platform"
assembly="Platform"
default-cascade="save-update">
<joined-subclass name="Platform.PhysicalItem"
extends="Platform.SellableItem, Platform"
table="PHYSICALITEM">
<key column="UNIQUE_ID" />
</joined-subclass>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Platform"
assembly="Platform"
default-cascade="save-update">
<joined-subclass name="Platform.SellableItem"
extends="Platform.Item, Platform"
table="SELLABLEITEM">
<key column="UNIQUE_ID" />
</joined-subclass>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Platform"
assembly="Platform"
default-cascade="save-update">
<class name="Platform.Item" table="ITEM">
<id name="UniqueId" column="UNIQUE_ID" type="string"
<generator class="uuid"/>
</id>
<version name="Version" type="long" column="VERSION" unsaved-value="negative" />
</class>
</hibernate-mapping>
Code:
Code: