| In the attached testcase, RefEntity references the BaseType of a JOINED inheritance. Both SubType1 and SubType2 contain a property named myvalue. When creating a treated join from RefEntity to SubType1 or SubType2, and restricting myvalue, the restriction is always on SubType2.myvalue. For both queries, the JPAQL is:
select generatedAlias0 from RefEntity as generatedAlias0 inner join generatedAlias0.other as generatedAlias1 where generatedAlias1.myvalue=:value
The treat is lost during rendering from criteria to JPAQL and Hibernate simply picks the first (or last) subtype with a property named myvalue. A workaround for this problem is to name the properties differently. |