| The behavior is expected. The first query uses DISTINCT to avoid deduplication on the parent entity since the ResultSet size is P x C where P is the number of Parent entities being fetched while N is the number of Child objects. In the first query, Hibernate can transform the table-based ResultSet into a graph of entities, hence we can remove the duplicated parent object references. In the second query, table-based ResultSet will no longer become a graph of objects since the Tuple result is tabular as well, like a spreadsheet. Hence, DISTINCT will have no effect since it does not influence either the SQL query or can it remove any object reference duplicates. |