Association relationship Mapping
The correlation mapping is a complex mapping relationship in the mapping relationship, which has a pair of more than one or one pairs and many pairs of relationships. They are subdivided into one-way and two-way points. Let's introduce each of the following.
One-way Onetoone
One-way one-to-one is the simplest of the relational mappings, simply that you can query the other party from the associated side, but not the reverse. We use the example below to illustrate that the person entity class in Listing 1 and the address class in Listing 2 are one-way one-to-one relationships where we can query the content of a person's corresponding address, but we can't query the value of an address The person that corresponds to the value.
Listing 1. Owning side of one-way one-to-one relationship
@Entity public
class person implements Serializable {
private static final long serialversionuid = 1L;
@Id
@GeneratedValue (strategy = generationtype.auto)
private Long Id;
private String name;
private int age;
@OneToOne
private address address;
Getters & Setters
}
Listing 2. The opposite end of one-way one-to-one relationship
@Entity public
class address implements Serializable {
private static final long serialversionuid = 1L;
@Id
@GeneratedValue (strategy = generationtype.auto)
private Long Id;
Private String Street;
Private String city;
Private String country;
gettes& Setters
}
Figure 1. ER diagram of one-way one-to-one relationship