Postgresql在休眠中``选择不同的开启'' [英] Postgresql 'select distinct on' in hibernate

查看:107
本文介绍了Postgresql在休眠中``选择不同的开启''的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

休眠状态是否支持在查询中选择不同的内容?

Does hibernate has support on select distinct on queries?

SELECT DISTINCT ON (location) location, time, report
FROM weather_reports
ORDER BY location, time DESC;

是否可以为该查询创建休眠条件?

Is there a way to create hibernate criterias for that query?

推荐答案

由于这里存在所有怀疑和猜测,因此当我偶然发现此问题时,我肯定会回答:

Since there was all "suspecting" and "guessing" here, when I stumbled across this question, I'll answer it definitely:

不,Hibernate不支持DISTINCT ON查询。

No, Hibernate does not support a DISTINCT ON query.

org.hibernate.hql.internal.ast.QuerySyntaxException: 
unexpected token: ON near line 1, column 17
[SELECT DISTINCT ON (location) location, time, report FROM weather_reports ORDER BY location, time DESC]

经过Hibernate 4.3.9-final测试

Tested under Hibernate 4.3.9-final

请注意不适用于普通的DISTINCT查询。
请参见 https://stackoverflow.com/questions / 263850 ...

Please note that this doesn't apply to normal DISTINCT queries. See https://stackoverflow.com/questions/263850...

这篇关于Postgresql在休眠中``选择不同的开启''的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆