-->
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: Polymorphic Query
PostPosted: Mon Oct 09, 2006 4:28 am 
Newbie

Joined: Mon Oct 09, 2006 4:14 am
Posts: 1
i do have an inheritance tree of 3 classes: subject, person and organisation. subject is my abstract superclass whereas person and organisation do inherit from subject and are concrete classes.

i have mapped this classes in hibernate 3.1.3 using the table-per-subclass strategy. now i want to fetch all persons and organisations using the criteria query api. i used

Code:
DetachedCriteria.forClass(Subject.class);


this criteria returns to me instances of subject, person and organisation (i made subject non-abstract meanwhile).

my question is: how do i have to conifg hibernate to return me only persons and organisations and to ommit subjects?

here the mapping i use as an example:

Code:
<hibernate-mapping package="com.example">
   <class name="Subject" table="subject">
      <id name="id" type="integer" column="subject_id">
         <generator class="seqhilo">
            <param name="sequence">bip_domain</param>
            <param name="max_lo">100</param>
         </generator>
      </id>
      <joined-subclass name="Person" table="person">
         <key column="subject_id"/>
      </joined-subclass>
      <joined-subclass name="Organisation" table="organisation">
         <key column="subject_id"/>
      </joined-subclass>
   </class>
</hibernate-mapping>


any suggestions?

thx in advance, Gaetano


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 3:15 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
How can you have Subject instances as Subject is abstract ?

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


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.