[hibernate-dev] Question regarding DISTINCT

Michael Barker mbarker at buni.org
Mon Feb 19 08:56:05 EST 2007


Hi,

When querying for a list of objects using ejb-ql, the keyword 'distinct' 
is used to de-duplicate the result set and give a correct list of 
objects.  However I have noticed that everytime distinct is specifed in 
the ejb-ql query it also gets specified in the sql query.  I am curious 
as the reasoning behind this.  I understand that distinct is used to 
remove duplicates from the SQL result set, but from what I can see, for 
the majority of simple use cases the sql distinct is superflous.  
Running the hibernate generated query without the distinct returns the 
same results.  I assume that the distinct is in there for are reason, 
are there some more complicated use cases for which the distinct in 
necessary?

My main concern is performance, is there anyway of performing an ejb-ql 
"select distinct..." without hibernate issuing an sql "select distinct...".

Regards,
Michael Barker.



More information about the hibernate-dev mailing list