I have an AbstractFish object with two joined subclasses Shark and Trout. See the mapping below. (Note: these are just test classes. :)
When I run the following HQL query....
from AbstractFish f where f.id = 1
...everything works out fine, so I am fairly confident that my mappings are correct.
When I run this HQL query...
from AbstractFish f where f.class = com.matrix.bo.Shark
nothing is returned. I do not get an error, but my object is not returned and I know I have data, because I can load the object using a different query.
I have a similar example that uses the table-per-hierarchy with discriminators and the "class" attribute works fine with similar queries.
Question) Does the special attribute "class" in the hibernate query language not work for joined-subclass?
Code:
<hibernate-mapping>
<class
name="com.matrix.bo.AbstractFish"
table="Fish"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="Fish_ID"
type="int"
unsaved-value="0"
>
<generator class="native">
</generator>
</id>
<property
name="color"
type="string"
update="true"
insert="true"
column="Color"
length="70"
not-null="true"
unique="false"
/>
<property
name="name"
type="string"
update="true"
insert="true"
column="Name"
length="50"
not-null="true"
unique="false"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-AbstractFish.xml
containing the additional properties and place it in your merge dir.
-->
<joined-subclass
name="com.matrix.bo.Shark"
table="Shark"
dynamic-update="false"
dynamic-insert="false"
>
<key
column="Fish_ID"
/>
<property
name="toothSize"
type="string"
update="true"
insert="true"
column="ToothSize"
length="35"
not-null="true"
unique="false"
/>
</joined-subclass>
<joined-subclass
name="com.matrix.bo.Trout"
table="Trout"
dynamic-update="false"
dynamic-insert="false"
>
<key
column="Fish_ID"
/>
<property
name="smell"
type="string"
update="true"
insert="true"
column="Smell"
length="40"
not-null="true"
unique="false"
/>
</joined-subclass>
</class>
</hibernate-mapping>