Considering the following parent entity:
and its child-side relationship:
Hibernate returns a List<Call> instead of a List<Person>.
Criteria.DISTINCT_ROOT_ENTITY is intended to be used with an org.hibernate.Criteria. It should not be used with native queries.
The bug still replicates when using the DistinctRootEntityResultTransformer:
Instead of a List of Phone we get a List of Call objects.
This issue needs to be reopened.
DistinctRootEntityResultTransformer assumes that the root entity is last. IIRC, an HQL query returns the root entity last, so DistinctRootEntityResultTransformer should work properly for an HQL query.
The transformer would probably work for a native query using a SELECT clause like: SELECT c., ph. ...". If so, I'm OK with re-opening this as a documentation issue. WDYT?
It works for the HQL queries I created for the User Guide.
For SQL queries, even if I rewrite it like this:
the result will be a List<Call> instead of a List<Phone>.