I have a Project that has many Tasks.
I have a SQL query that returns all the projectIds for a userId by querying the TASKS table … here it is:
SELECT DISTINCT(projectId)
FROM TASKS
WHERE userId = '55' AND status = 'IN_PROGRESS';
First, I’m wondering is there an easy JPA way to get all the Project objects given the list of project ids?
Second, how can I make a JPA query that does what this SQL does? I’m guessing it would have to be something like:
SELECT DISTINCT(Project p)
WHERE /*one of the tasks*/ p.tasks[].userId = '55' AND p.tasks[].status = 'IN_PROGRESS';
But I have no idea. Any suggestions are GREATLY appreciated!
Rob
I’m wondering is there an easy JPA way to get all the Project objects given the list of project ids
how can I make a JPA query that does what this SQL does?
Read documentation about JPQL, because this is pretty basic stuff. Here’s the Hibernate documentation on HQL, which is a small superset of JPQL.