Quote:
I tried using "SELECT DISTINCT pg.name, pd.id ...", but that gave me a QueryException about expecting an aggregate function
Huh!!?? Are you sure? That should work perfectly.
The corrrect query is:
Code:
SELECT pg.name, pg.id
FROM PollGroup pg
LEFT JOIN pg.polls p
WHERE
pg.owner = :usr
OR :usr IN elements(pg.pollCreators)
OR p.owner = :usr
OR :usr IN elements(p.editors)
ORDER BY pg.name
or, probably even better:
Code:
SELECT pg.name, pg.id
FROM PollGroup pg
LEFT JOIN pg.polls p
LEFT JOIN p.editors ed
LEFT JOIN pg.pollCreators c
WHERE pg.owner = :usr
OR ed = :usr
OR p.owner = :usr
OR c = :usr
ORDER BY pg.name