Hibernate new keyword with distinct

可紊 提交于 2019-12-29 06:43:28

问题


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.


回答1:


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 ...


来源:https://stackoverflow.com/questions/6984135/hibernate-new-keyword-with-distinct

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!