OK, after reading the FAQ and doing a little digging on the forums I'm still pretty much in the dark over why there's a discrepancy between what the docs say and the actual result.
The Hibernate FAQ entry entitled "Hibernate does not return distinct results for a query with outer join fetching enabled for a collection (even if I use the distinct keyword)" says:
Quote:
Query result lists are always exactly the same size as the underlying JDBC ResultSet.
But *why*? This means that I need to know whether the query is going to perform an outer join fetch to know whether or not I need to distinctify the results. Otherwise, I might remove duplicate instances that are supposed to be in a result set, right?
I've been putting together a web service API to allow users to execute arbitrary HQL queries against my domain model. To do this I've generated proxy classes with an IsLazy property and am making all lazy objects and collections in the query result set return an unpopulated proxy marked lazy. It was my intention to allow the user to populate a selected collection property of each returned object by using the "join fetch" HQL construct, but then it skews the result set.
I suppose I could try parsing the HQL statement for "join fetch" to determine whether or not I need to distinctify the results, but this just seems like a bit of a kludge.
Why was the choice was made to make the result set match the size of the underlying DB result set? This should probably be in the docs since it directly contradicts what's currently written there.
Cheers,
Symon.