簡體   English   中英

Postgresql'在hibernate中選擇distinct'

[英]Postgresql 'select distinct on' in hibernate

hibernate是否支持select distinct on query?

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

有沒有辦法為該查詢創建hibernate標准?

既然這里有“懷疑”和“猜測”,當我偶然發現這個問題時,我肯定會回答:

不,Hibernate不支持DISTINCT ON查詢。

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下測試

請注意,這不適用於普通的DISTINCT查詢。 請參閱https://stackoverflow.com/questions/263850 ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM