JPA - getting distinct value from one column

我们两清 提交于 2019-12-12 12:53:22

问题


I have an entity that has few fields. One of them is city name. Now I want to get list of all distinct cities from that table. How can I archive that. I tried using DISTINCT keyword, but it doesn't work.

I'm using Hibernate as JPA provider but I would like to get it in pure JPA Query.


回答1:


Have you tried:

SELECT DISTINCT t.city FROM MyTable t


来源:https://stackoverflow.com/questions/3600870/jpa-getting-distinct-value-from-one-column

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