-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: MappingException on discriminator - invalid child element
PostPosted: Fri Oct 28, 2005 9:56 am 
Newbie

Joined: Fri Oct 28, 2005 9:46 am
Posts: 1
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 28, 2005 11:38 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
The <discriminator> must be just after <id>...

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.