nerdexam
Oracle

1Z0-860 · Question #45

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, @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")
  • D@ManyToMany(targetEntity=Project.class) on the projects field, @ManyToMany on the emps field

How the community answered

(43 responses)
  • A
    7% (3)
  • B
    2% (1)
  • C
    77% (33)
  • D
    14% (6)

Community Discussion

No community discussion yet for this question.

Full 1Z0-860 Practice