The Contact Information embeddable class contains address information as well as a reference to a phone entity. The ContactInformation class is defined as follows:
@Embeddable public class ContactInformation {
String street;
String city;
@OneToOne Phone phone;
}
The developer wants to use this class in an Employee entity, but override the default name of the foreign key to the Phone entity.
Which of the code segments shows how to do this correctly?
A.
@Entity public class Employee {
@Id int empId;
@AssociationOverride (name = empInfo.phone�, joinColumn = @JoinColumn)
(name = �INFO_FK�))
ContactInformation empInfo;
}
B.
@AssociationOverride (name = �empInfo.phone�, joinColumn = �INFO_FK�)
@Id int empId;
@ContactInformation empInfo;
}
C.
@ AssociationOverride (name = �empInfo.phone�, joinColumn = �INFO_FK�)
Entity public class Employee {
@Id int empId;
}
D.
Entity public class Employee {
@Id int empId;
@ AssociationOverride (name = �empInfo.phone�, joinColumn = �INFO_FK�)
ContactInformation empInfo;
}
Explanation:
http://docs.oracle.com/javaee/6/api/javax/persistence/AssociationOverride.html
The correct answer is missing, but A is the closest to it.
The correct answer is A with some correctation
@AssociationOverride(name=”phone”,
joinColumns=@JoinColumn(name=”INFO_FK”)),
Correct
yes , It should be joinColumns instead of joinColumn.
Agree with Andrei.