according to JPA specification treat operator has two functions : filtering and downcasting.
as it appears from the translated SQL queries and the returned results, the implemented functionality is not in match with spec(I think). In the following I describe some of the cases :
treat operator and join
in this case when the association is single-valued a filtering condition based on Discriminator is added to generated SQL query but when the association is multi-valued, no filtering condition is added to generated query.
treat operator and sub-classes with the similar field names
in single-table inheritance scheme, when sub-classes has fields with the same name(mapped to separate table columns), by using treat operator along with conditions on common-named fields, we expect the column names of the related field of the treat-ed type in generated query but this is not the case.
based on the above cased, I think, the filtering and downcasting functionality of treat operator is not implemented properly.
any idea if I am wrong or there is some problems in the implementation of treat ?
tested versions : hibernate 5.3 and 5.6
thank you