Treat on joined inheritance with identical property names results in wrong query
Description
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:
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.
In the attached testcase,
RefEntity
references theBaseType
of aJOINED
inheritance. BothSubType1
andSubType2
contain a property namedmyvalue
. When creating a treated join fromRefEntity
toSubType1
orSubType2
, and restrictingmyvalue
, the restriction is always onSubType2.myvalue
. For both queries, the JPAQL is: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.