hey everybody,
I'm struggling to find the solution for the following problem: I want to get all the picture albums which have at least one picture.
In SQL i would to something like:
SELECT pa.id
FROM album pa
JOIN picture pi
ON pa.id = pi.album_id
GROUP BY pa.id
HAVING count(pi.id) > 0
But I don't know how to do this in JPQL...
Obviously, my album entity has a collection of pictures, but also a User in Many-to-One relation to make it more interesting.
SELECT pa
FROM album pa
JOIN pa.pictures pi
GROUP BY pa
HAVING count(pi) > 0
This is a natural guess I think, but it does not work like this.
So please if anyone has a solution or hint or the point that I'm missing, let me know!
Thanks for any help in advance!
cheers, balázs