Oracle
1Z0-860 · Question #60
Given two entities with a many-to-many bidirectional association between them: 11. @Entity public class Employee! 12. Collection projects; 13. // more code here 14.} and 11.〦ntity public class…
The correct answer is C. @ManyToMany(targetEntity=Project.class) on the projects field, @ManyToMany(mappedBy="projects"). See the full explanation below for the reasoning.
Question
Given two entities with a many-to-many bidirectional association between them: 11. @Entity public class Employee! 12. Collection projects; 13. // more code here 14.} and 11.〦ntity public class Project! 12. Set<Employee> emps; 13. // more code here 14.} What set of annotations correctly defines the association?
Options
- A@ManyToMany on the projects field,
- B@ManyToMany(mappedBy="emps") on the projects field,
- C@ManyToMany(targetEntity=Project.class) on the projects field, @ManyToMany(mappedBy="projects")
- D@ManyToMany(targetEntity=Project.class) on the projects field, @ManyToMany on the emps field
How the community answered
(34 responses)- A9% (3)
- B3% (1)
- C74% (25)
- D15% (5)
Community Discussion
No community discussion yet for this question.