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.