I hava a table with a column called description. An ajax drop down runs the query, allowing users autocompletion for descriptions they have previously entered.
The problem I'm having is eliminating duplicate descriptions from the query. For example, if I had 300 rows with the description "computer", I only want to display "computer" once.
I can think of some hacky ways like storing the resulting list as a hashset with the description set as the key to filter out duplicates, but I'd prefer to have some way for the database to do it since I'd like to limit the results.
Here is the sql query. It works as you'd expect I just don't know how to say, only return one row if descriptions are equal to each other.
HQL:
Code:
select commodity from UsShipment shipment left join shipment.commodities commodity where shipment.carrierVersion.carrier.id = :carrierId and lower( commodity.description ) like :description order by lower( commodity.description )
Result is of type List<Commodity>...
Thanks in advance for any help...