nerdexam
Oracle

1Z0-898 · Question #36

A developer is creating an entity which is mapped to a table that has a primary key constraint defined on two character columns and would like to use mapping defaults as much as possible to simplify…

The correct answer is C. Use a separate @Embeddable class to map those two columns and use an @EmbeddedId E. Use a separate class to map those two columns. Specify that class using @Idclass annotation on. C: Annotation Type EmbeddedId Applied to a persistent field or property of an entity class or mapped superclass to denote a composite primary key that is an embeddable class. The embeddable class must be annotated as E: Annotation Type IdClass Specifies a composite primary key…

JPA Fundamentals

Question

A developer is creating an entity which is mapped to a table that has a primary key constraint defined on two character columns and would like to use mapping defaults as much as possible to simplify the code. Which two mapping options can be chosen? (Choose two.)

Options

  • AUse an @id property that constructs a private field as a concatenation of two columns.
  • BUse a separate class to map those two columns and use an @idclass annotation to denote I
  • CUse a separate @Embeddable class to map those two columns and use an @EmbeddedId
  • DUse a separate @Embeddable class to map those two column and add two fields or properties
  • EUse a separate class to map those two columns. Specify that class using @Idclass annotation on

How the community answered

(37 responses)
  • A
    16% (6)
  • B
    3% (1)
  • C
    73% (27)
  • D
    8% (3)

Explanation

C: Annotation Type EmbeddedId Applied to a persistent field or property of an entity class or mapped superclass to denote a composite primary key that is an embeddable class. The embeddable class must be annotated as E: Annotation Type IdClass Specifies a composite primary key class that is mapped to multiple fields or properties of the entity.The names of the fields or properties in the primary key class and the primary key fields or properties of the entity must correspond and their types must be the same. @IdClass(com.acme.EmployeePK.class) public class Employee { @Id String empName; @Id Date birthDay;

Topics

#composite primary key#@IdClass#@EmbeddedId#@Embeddable

Community Discussion

No community discussion yet for this question.

Full 1Z0-898 Practice