In this section we modify our object model and make it bidirectional. We will also take the opportunity to override some mapping defaults. Shown below is a UML diagram for the bidirectional model.
A Customer entity can now be referenced by Account and Address entities. However, we still leave the Customer and Referee relationship unidirectional; we have no need in our application to reference a Customer entity from a Referee entity.
First we modify the Customer entity; the listing is shown below with modifications highlighted. We will discuss these modifications in detail.
@Entity public class Customer implements Serializable { private int id; private String firstName; private String lastName; private Referee referee; private Collection<Address> addresses; private Collection<Account> accounts; public Customer() {} @Id @Column(name="CUSTOMER_ID") public int getId() { return id; } public void setId(int id) { this.id = id; } @Column...