我需要采取目前的 hql :
select distinct a from Asset as a where ...
并将其更改为
select new com.org.AssetDTO(a.id, a.address, a.status) from Asset as a where ...
我的问题是不同的关键字。它在您使用新对象查询类型的 hql 查询中属于哪里。一个想法是使用子选择并在那里有我的独特之处。我试过添加
distinct a.id
但这不起作用。
最佳答案
对于任何感兴趣的人来说,正确的语法是好的
select distinct new com.org.AssetDTO(a.id, a.address, a.status) from Asset as a where ...
关于使用不同的 hibernate 新关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6984135/