Hello,
I'm working on mapping some objects in an inheritance tree. I set up the mapping exactly as I've seen in examples, but I got a MappingException when I tried to run some tests. Here's the exception message:
The element 'urn:nhibernate-mapping-2.0:class' has invalid child element 'urn:nhibernate-mapping-2.0:discriminator'.
I thought it might be a problem with the xsd built into the RC I was using, so I tried 1.0 and found I had the same issue. I also built NHibernate from the 1.0 sources to no avail. When I open the nhibernate-mapping-2.0.xsd file, I see that the class element has a reference to the discriminator element, so I can't really figure out what's going wrong. Here's the mapping as I have it:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Synxis.Enterprise.Business.HotelGroups.HotelGroup, Business" table="Chain">
<id name="UniqueID" column="Chain_Guid" type="System.Guid" access="nosetter.camelcase" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid" />
</id>
<property name="ShortID" column="Chain_ID" type="Int32" access="nosetter.camelcase" insert="false" update="false" />
<property name="Code" column="Chain_CD" type="String(12)" />
<property name="Name" column="Chain_NM" type="String(60)" />
<bag name="HotelsList" table="Hotel_Chain" inverse="true" lazy="true">
<key column="Chain_Guid" />
<many-to-many class="Synxis.Enterprise.Business.Hotels.Hotel, Business" column="Hotel_Guid" />
</bag>
<many-to-one name="ParentChain" column="Parent_Chain_Guid" class="Synxis.Enterprise.Business.HotelGroups.Chain, Business" />
<discriminator column="Chain_Typ_ID" type="Int32" />
</class>
</hibernate-mapping>
As you can see, I have the subclasses in separate files (that have <subclass> tags with the extends attribute). I even tried putting them in the same file without any luck.
Let me know if you need more information - thanks a lot in advance!
-Andrew