Okay, I'm hoping this will be straight forward enough that I don't have to post my model. On the following named query:
Code:
SELECT c.user
FROM Contact c
WHERE c.owner = :ownerID
GROUP BY c.user.id;
Is giving me an exception stating that GROUP BY is using the userId column from the Contact entity while SELECT is using the column from the entity User.
Additional information, I am only doing the GROUP BY to avoid this query:
Code:
SELECT DISTINCT c.user FROM Contact c WHERE ...;
Since the distinct would do a sort on ALL fields on the User entity. I suppose if this type of GROUP BY is not supported by Hibernate I could always do the following:
Code:
SELECT u FROM User u WHERE u.id IN ( SELECT c.user FROM Contact c WHERE ... );
But that would seem less optimal than the GROUP BY.
Thanks!