Hi
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:Code:employee: empId, name project: projId, name emp_proj: empId, projId class Employee{ ... @ManyToMany @JoinTable(.....) Collection<Project> projects; .... } class Project ... @ManyToMany(mappedby="projects") 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.Code: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?
Thanks
Amit Khanna


Reply With Quote
