The developer wants to override the default mappings for an embeddable class Address used by the customer entity.
The Address class is defined as follows:
@Embeddable public class Address (
private String street;
private String city;
private String country;
. . .
)
Assume that NO mapping descriptor is present.
Which code segment below shows the correct way to override the default mapping for address?
A.
@AttributeOverrides ({
@AttributeOverride (name = �street�, column = @Column (name = ADDR_STREET)),
@AttributeOverride (name = �city, column = @Column (name = ADDR_CITY)),
@AttributeOverride (name = �country, column = @Column (name = ADDR_COUNTRY)),
}}
@Embedded Address addr;
B.
@ AttributeOverrides ({
@AttributeOverride (name = �street�, column = @Column (name = �name_STREET�)),
@AttributeOverride (name = �city, column = @Column (name = �name_CITY�)),
@AttributeOverride (name = �country, column = @Column (name = �name_COUNTRY�)),
}}
@Embedded Address addr;
C.
@ AttributeOverrides ({
@AttributeOverride (name = �street�, column (name = �name_STREET�)),
@AttributeOverride (name = �city, column (name = �name_CITY�)),
@AttributeOverride (name = �country, column (name = �name_COUNTRY�)),
}}
@Embedded Address addr;
D.
@AttributeOverrides ({
@AttributeOverride (name = �addr.street�, column = @Column (name = ADDR_STREET)),
@AttributeOverride (name = �addr.city�, column = @Column (name = ADDR_CITY)),
@AttributeOverride (name = �addr.country�, column = @Column (name = ADDR_COUNTRY)),
}}
@Embedded Address addr;
Explanation:
http://docs.oracle.com/javaee/5/api/javax/persistence/AttributeOverrides.html
B
A
B ! name of the column should be in double coat.
Agree
answer: B
example :
@Embedded
@AttributeOverrides({
@AttributeOverride(name = “area”, column = @Column(name = “landmark”)),
@AttributeOverride(name = “pincode”, column = @Column(name = “postal_code”)) })
private Address address;