Part has a field, vendorPart, that has a one-to-one relationship with VendorPart’s part field. That is, each part has exactly one vendor part, and vice versa.
Here is the relationship mapping in Part:
@OneToOne(mappedBy="part")
public VendorPart getVendorPart() {
return vendorPart;
}
Here is the relationship mapping in VendorPart:
@OneToOne
@JoinColumns({
@JoinColumn(name="PARTNUMBER",
referencedColumnName="PARTNUMBER"),
@JoinColumn(name="PARTREVISION",
referencedColumnName="REVISION")
})
public Part getPart() {
return part;
}
Note that, because Part uses a compound primary key, the @JoinColumns annotation is used to map the columns in the EJB_ORDER_VENDOR_PART table to the columns in EJB_ORDER_PART. EJB_ORDER_VENDOR_PART’s PARTREVISION column refers to EJB_ORDER_PART’s REVISION column.