I have two entities Employee and Project in my application and there is many to many relationship between them. The application uses JPA and Hibernate. I have three tables:
Now I want to add information that who assigned a particular project to the employee, so the modified table looks like this:
employee: empId, name
project: projId, name
emp_proj: empId, projId
private Collection<Employee> employees;
Since assignee is not the attribute of any of the two entities [i.e. employee or project] i can't access it.
emp_proj: empId, projId, assignee.
One solution to this is that I make another entity for table emp_proj and break the relationship into two OneToMany relationships employee -> emp_proj and project -> emp_project.
Can anyone suggest a better solution by which i can access the attributes of the relationship?