What set of annotations correctly defines the association?

Given two entitles with a many-to-many bidirectional association between them:
11. @Entity public class Employee {
12. Collection projects;
13. //more code here
14. }
and
11. @Entity public class Project{
12. Set<Employee> emps;
13. //more code here
14. }
What set of annotations correctly defines the association?

Given two entitles with a many-to-many bidirectional association between them:
11. @Entity public class Employee {
12. Collection projects;
13. //more code here
14. }
and
11. @Entity public class Project{
12. Set<Employee> emps;
13. //more code here
14. }
What set of annotations correctly defines the association?

A.
@ManyToMany on the projects field,
@ManyToMany(mappedBy=”projects”) on the emps field

B.
@ManyToMany(mappedBy=”emps”) on the projects field,
@ManyToMany on the emps field

C.
@ManyToMany(targetEntity=Project.class) on the projects field,
@ManyToMany(mappedBy=”projects”) on the emps field

D.
@ManyToMany(targetEntity=Project.class) on the projects field,
@ManyToMany on the emps field



Leave a Reply 0

Your email address will not be published. Required fields are marked *