From what I could gather from the problem statement:-
- Person - can exists without job. Can have zero or more Job(s).
- Job - Can exist independent of Person(s) performing it.
A cleaner way would be to have a entity (and thus its table) that encapsulate this mapping:-
class Employment{
private Person person;
private Job job;
}
Now you can query from both ends. Like:-
- SELECT FROM EMPLOYMENT WHERE PERSON.ID=xyz
This might give 0 or more rows.
Each row will have information of mapped Job too.
So in this case you will have your service/repository something like:-
interface EmployementRepository{
// CRUD methods on Employement.
}