I am using this JPA-Query (EclipseLink):
SELECT e FROM Entity e GROUP BY e.label
But i get all rows in my result开发者_如何学C instead of only the unique labels.
My second approach was using DISTINCT like i did successfully in another function which counts the distinct values, but i don't know how apply this to get the Entities:
SELECT COUNT(DISTINCT e.label) FROM Entity e
From the Hibernate JP-QL documentation:
select distinct e.label from Entity e
However, it seems you want the full entities, which I don't think is possible.
actually, it is possible, for example :
@NamedQuery(name = "WorkingDay.WorkersAtADay", query = "SELECT DISTINCT w.worker FROM WorkingDay w WHERE w.date = :Date"),
精彩评论