从SQL查询转化为HQL查询问题
我是 hibernate 用户才几天,我遇到了一个问题。
我不知道如何将此 SQL 查询转换为 HQL:
SELECT name, street, city, description
, (SELECT AVG(rate)
FROM user_restaurant_rating
WHERE user_restaurant_rating.restaurant_id = restaurants.id) AS rate
FROM restaurants
ORDER BY rate DESC
LIMIT 0,3
我读过一些教程,但还没有找到如何转换它。
先感谢您。
I'm a hibernate user for only a few days and I came across a certain problem.
I can't work-out how to translate this SQL query into HQL:
SELECT name, street, city, description
, (SELECT AVG(rate)
FROM user_restaurant_rating
WHERE user_restaurant_rating.restaurant_id = restaurants.id) AS rate
FROM restaurants
ORDER BY rate DESC
LIMIT 0,3
I've read few tutorials, but haven't found how to translate it.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Hibernate 参考 指示子选择在 select 子句中受支持。因此你应该能够写
The Hibernate reference indicates that subselects in the select clause are supported. You should thus be able to write