Following class structure is given:
class Job
{
String description;
Collection<JobHistory> history;
}
class JobHistory
{
Date assignDate;
User jobOwner;
}
class JobOwner
{
String name;
String id;
}
This class-structure is accessible on the db via JPA. In the DAO-Layer I can write queries in JPA syntax.
The Problem: I want a list with Job
and JobHistory
entries for a given owner with given id and who is the last one in the Jobhistory
of the job (ordered by assignDate). Sounds quite complicated, perhaps simpler: give me all jobs and JobHistory
where specified owner is the actual owner of the job.
Update: for clarity I will slightly change the names of the classes.
class Job
{
String description;
Collection<JobOwnerHistory> history;
}
class JobOwnerHistory
{
Date assignDate;
User jobOwner;
}
class JobOwner
{
String name;
String id;
}
Every Job
has a history of his owners sorted by assignDate
. The actual owner got the job last assigned (i.e. MAX(assignDate)
). I want find for every job the JobOwnerHistory
entry with MAX(assignDate)
for a specific user User
.