nerdexam
Oracle

1Z0-898 · Question #2

Given two entities with many-to-many bidirectional association between them: What set of annotations correctly defines the association?

The correct answer is C. @manyToMany ()targetEntity = project.class) on the projects field. Every many to many relationship has obviously two sides: a Owning side and the Inverse side (which is... non-owning). Here the Employee class is the owning side. targetEntity:The entity class that is the target of the association.The dot (".") notation syntax must be used in…

EJB Lite

Question

Given two entities with many-to-many bidirectional association between them:

What set of annotations correctly defines the association?

Exhibit

1Z0-898 question #2 exhibit

Options

  • A@manyToMany on the projects field,
  • B@manyToMany (mappedBy = emps) on the projects field,
  • C@manyToMany ()targetEntity = project.class) on the projects field,
  • D@manyToMany (targetEntity = Project.class) on the projects field,

How the community answered

(38 responses)
  • A
    16% (6)
  • B
    3% (1)
  • C
    74% (28)
  • D
    8% (3)

Explanation

Every many to many relationship has obviously two sides: a Owning side and the Inverse side (which is... non-owning). Here the Employee class is the owning side. targetEntity:The entity class that is the target of the association.The dot (".") notation syntax must be used in the mappedBy element to indicate the relationship attribute within the embedded This mappedBy element is mandatory and must be placed on the Inverse side of the relationship in case we are mapping a Bidirectional.Here Projects class is on the inverse side. Note: @manyToMany defines a many-valued association with many-to-many multiplicity. Every many-to-many association has two sides, the owning side and the non-owning, or inverse, side. The join table is specified on the owning side. If the association is bidirectional, either side may be designated as the owning side. If the relationship is bidirectional, the non-owning side must use the mappedBy element of the ManyToMany annotation to specify the relationship field or property of the owning side.

Topics

#@ManyToMany#bidirectional association#mappedBy#JPA relationship mapping

Community Discussion

No community discussion yet for this question.

Full 1Z0-898 Practice