-->
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.  [ 1 post ] 
Author Message
 Post subject: Retrieving superclass.
PostPosted: Tue Jul 08, 2008 4:47 pm 
Newbie

Joined: Fri Jul 04, 2008 3:53 pm
Posts: 2
Hi. I've got two classes, Genus and Species. Species extends Genus. I've defined a joined-subclass in the xml, and I can't seem to retrieve just a list of the Genus objects.

Mapping documents:
Code:
<hibernate-mapping>
   <class name="businessObjects.Genus" table="GENUS">
      <id name="genusId" column="ID">
         <generator class="increment" />
      </id>
      <property name="genusName" column="NAME" not-null="true" />
      <joined-subclass name="businessObjects.Species"
         table="SPECIES">
         <key column="GENUS_ID" foreign-key="SPECIES_GENUS_ID" not-null="true" />
         <property name="speciesId" column="ID" not-null="true" />
         <property name="speciesName" column="NAME" not-null="true" />
      </joined-subclass>
   </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
session.createQuery("from Genus order by genusName").list();

The generated SQL (show_sql=true):
Code:
select
        genus0_.ID as ID4_,
        genus0_.NAME as NAME4_,
        genus0_1_.ID as ID5_,
        genus0_1_.NAME as NAME5_,
        decode(genus0_.ID,
        genus0_1_.GENUS_ID,
        1,
        0) as clazz_
    from
        CNPHI_ESP_GENUS genus0_,
        CNPHI_ESP_SPECIES genus0_1_
    where
        genus0_.ID=genus0_1_.GENUS_ID(+)
    order by
        genus0_.NAME


I don't want to join the GENUS table with the SPECIES table. I just want to get everything from GENUS. Any help would be much appreciated.


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

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.