Reputation: 5086
I need to take hql that is currently :
select distinct a from Asset as a where ...
and change it to
select new com.org.AssetDTO(a.id, a.address, a.status) from Asset as a where ...
My problem is with the distinct keyword. Where does it belong in an hql query where you're using the new Object query type. One thought was to use a sub-select and have my distinct there. I've tried adding distinct a.id
but that doesn't work.
Upvotes: 18
Views: 12026
Reputation: 5086
Ok for anyone interested the proper syntax is
select distinct new com.org.AssetDTO(a.id, a.address, a.status) from Asset as a where ...
Upvotes: 29