Hibernate new 关键字具有不同的

发布于 2024-11-28 05:50:33 字数 345 浏览 2 评论 0原文

我需要获取当前的 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 ...

My Problem is with the unique 关键字。它属于使用新对象查询类型的 hql 查询中的哪个位置。一种想法是使用子选择并在那里有我的独特之处。我尝试添加 distinct a.id 但这不起作用。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌上青苔 2024-12-05 05:50:33

好的,对于任何感兴趣的人来说,正确的语法是

select distinct new com.org.AssetDTO(a.id, a.address, a.status) from Asset as a where ...

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 ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文