Home » Oracle » 1z0-898 » Which two of the code segments below can be used to model the state of ContractInformation?
The embeddable class ContractInformation is used in an element collection of the Employee entity.
@Entity
Public class Employee {
@Id int empId;
@ElementaryCollection Set <ContractInformation> info;
. . .
}
Assume that the phone class is an entity and that address is an embedded class.
Which two of the code segments below can be used to model the state of ContractInformation? (Choose two)
A. @OneToMany Set <phone> phones;
B. @Embeddable Address address;
C. @ManyToOne phone phone;
D. @ElementaryCollection <Phone> phones;
E. @OneToOne Address address;
Correct Answer: BC
Explanation/Reference:
Explanation:
B:Embeddable classes have the same rules as entity classes but are annotated with the javax.persistence.Embeddable annotation instead of @Entity.
Example:@EmbeddedZipCode zipCode;
C:@ManyToOnedDefines a single-valued association to another entity class that has many-to-one multiplicity.
Example2:
@Entity
public class Employee {
@Id int id;
@Embedded JobInfo jobInfo;
}
@Embeddable
public class JobInfo {
String jobDescription;
@ManyToOne ProgramManager pm; // Bidirectional
}
References:
Download Printable PDF. VALID exam to help you PASS.
|
|