nerdexam
Oracle

1Z0-898 · Question #53

The department entity has a unidirectional One To Many relationship to the employee entity. The developer wants to model this relationship as a java.util.map such that the key of map is true…

The correct answer is B. @OneToMany @mapKey (name, "name") map < integer, Employee> Employees. Annotation Type MapKeyspecifies the map key for associations of type java.util.Map when the map key is itself the primary key or a persistent field or property of the entity that is the value of

Entity Relationships

Question

The department entity has a unidirectional One To Many relationship to the employee entity. The developer wants to model this relationship as a java.util.map such that the key of map is true employee name. The primary key of the Employees entity is empId, an integer. Which of the following is correct?

Options

  • A@OneToMany (targetEntity = Employee.class)
  • B@OneToMany @mapKey (name, "name") map < integer, Employee> Employees;
  • C@OneToMany @MapKeyJoinColumn (name = "name") map <String, Employee>
  • D@OneToMany @mapsId (name = "name") map <String, Employee> employees;

How the community answered

(32 responses)
  • A
    9% (3)
  • B
    81% (26)
  • C
    3% (1)
  • D
    6% (2)

Explanation

Annotation Type MapKeyspecifies the map key for associations of type java.util.Map when the map key is itself the primary key or a persistent field or property of the entity that is the value of

Topics

#OneToMany#@MapKey#Map relationship#collection mapping

Community Discussion

No community discussion yet for this question.

Full 1Z0-898 Practice