I have a discriminator class with two subclasses in their own tables. They don't share property/columns names as they store different information. If I had the two subclasses and one had a propery status, but the other didn't, can I add a WHERE clause for that property?
With a mapping like this:
Code:
<hibernate-mapping>
<class name="com.myClass" table="classDiscriminatorTable" lazy="false" discriminator-value="0">
<id name="id" column="parentId">
<generator class="foreign">
<param name="property">lead</param>
</generator>
</id>
<discriminator column="classType" type="integer"/>
<subclass name="com.myClass.subClassA" discriminator-value="1">
<join table="classB">
<key column="parentId" />
<property name="response"/>
</join>
</subclass>
<subclass name="com.myClass.subClassB" discriminator-value="2">
<join table="classB">
<key column="parentId" />
<property name="status"/>
</join>
</subclass>
</class>
</hibernate-mapping>
Can I create a HQL query that uses myClass.subClassB.status:
Code:
String hql = "FROM Parent INNER JOIN FETCH myClass as myClass WHERE myClass.class = com.myClass.subClassB AND myClass.status = :status";
Thanks!