-->
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: Are two levels of subclasses possible?
PostPosted: Fri Jul 22, 2005 7:53 pm 
Regular
Regular

Joined: Fri May 13, 2005 4:08 pm
Posts: 64
I've got a User base class, then a Professional subclass, and then three subclasses of Professional. So I have a base class and two levels deep of subclasses. But the NHibernate mapping file I put together to persist the classes doesn't work as soon as I put in the 3rd level class. Apparently, the XML Schema for the mapping file doesn't allow <discriminator> tags under <subclass> tags, thereby forbidding nested classes. Hibernate 2.x documentation states that this should be allowed.

Is this just not implemented yet, or am I going about it incorrectly?

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-cascade="all-delete-orphan">
   <class name="Byu.Fhss.Sfl.RelateInstitute.Logic.Accounts.User, RelateInstituteLogic" table="`user`">
      <id name="Id" column="userId" unsaved-value="0">
         <generator class="native"/>
      </id>
      <discriminator column="userType" type="string"/>

      <property name="Username" unique="true"/>

      <subclass name="Byu.Fhss.Sfl.RelateInstitute.Logic.Accounts.Participant, RelateInstituteLogic" discriminator-value="participant">
         <property name="ReferralSite"/>
      </subclass>

      <subclass name="Byu.Fhss.Sfl.RelateInstitute.Logic.Accounts.Administrator, RelateInstituteLogic" discriminator-value="administrator">

      </subclass>

      <subclass name="Byu.Fhss.Sfl.RelateInstitute.Logic.Accounts.Professional, RelateInstituteLogic" discriminator-value="professional">
         <discriminator column="proType" type="string"/>

         <property name="IsApproved"/>

         <subclass name="Byu.Fhss.Sfl.RelateInstitute.Logic.Accounts.Clergy, RelateInstituteLogic" discriminator-value="clergy">

         </subclass>

         <subclass name="Byu.Fhss.Sfl.RelateInstitute.Logic.Accounts.Educator, RelateInstituteLogic" discriminator-value="educator">
            <property name="InstitutionName"/>
         </subclass>

         <subclass name="Byu.Fhss.Sfl.RelateInstitute.Logic.Accounts.Therapist, RelateInstituteLogic" discriminator-value="therapist">

         </subclass>
      </subclass>
   </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Yes, of course; my mistake
PostPosted: Fri Jul 22, 2005 11:58 pm 
Regular
Regular

Joined: Fri May 13, 2005 4:08 pm
Posts: 64
I found the problem. The line
Code:
<discriminator column="proType" type="string"/>

Did not belong. I found that even in nested subclass within subclass, only one discriminator column should exist, and the discriminator-value attribute for each level of subclass uses the same column as the base class.

Removing that one line fixed it. :) (to think I spent so long working on this!)


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.