-->
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: subclasses not working
PostPosted: Fri Apr 16, 2010 9:39 am 
Newbie

Joined: Thu Jan 21, 2010 5:08 am
Posts: 3
Hi,

First of all, I have subclasses with a discriminator working fine. When I load up a Person of type Employee it creates an Employee object for me, no problem[1].

My problem comes when I try to traverse a tree of these objects. I have a structure table, with person_id and person_parent_id. Starting with a Person (of whatever type) I can get all the Persons of which this Person is the parent (and I can recurse); but the Person that comes back from the PersonStructure domain object is a Person, not any particular subtype. So it looks like when the Person is loaded to populate the PersonStructure record it doesn't do any subclassing.

Does the Structure mapping file need to be told about the subclasses?

Snippet from Person.hbm.xml
Code:
<set name="personStructuresForPersonParentId" inverse="true" lazy="true" table="PERSON_STRUCTURE" fetch="select">
            <key>
                <column name="PERSON_PARENT_ID" not-null="true" />
            </key>

            <one-to-many class="eg.PersonStructure" />
        </set>

        <set name="personStructuresForPersonId" inverse="true" lazy="true" table="PERSON_STRUCTURE" fetch="select">
            <key>
                <column name="PERSON_ID" not-null="true" />
            </key>

            <one-to-many class="eg.PersonStructure" />
        </set>


Snippet from PersonStructure.hbm.xml
Code:
  <many-to-one name="personByPersonId" class="eg.Person" fetch="select">
            <column name="PERSON_ID" not-null="true" />
        </many-to-one>

        <many-to-one name="personByPersonParentId" class="eg.Person" fetch="select">
            <column name="PERSON_PARENT_ID" not-null="true" />
        </many-to-one>


[1] although interestingly, despite the "discriminator-column" it still left outer joins all the subclass tables.


Top
 Profile  
 
 Post subject: Re: subclasses not working
PostPosted: Sun Apr 18, 2010 4:28 pm 
Newbie

Joined: Thu Jan 21, 2010 5:08 am
Posts: 3
/bump

Surely someone else has encountered this or can comment upon it?


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.