The last blog post hibernate from Getting started to mastering (vii) multi-pair one-way association mapping we have mainly explained the multiple to one one-way association mapping, this time we continue to explain a pair of multiple one-way mapping.
One-to-many One-way Association mapping
Before explaining a One-to-many one-way association, follow our usual practice by looking at its corresponding class structure diagram and code. Specifically as follows:
public class Classes {private int id;
private String name;
Private Set students;
public int getId () {return id;
The public void setId (int id) {this.id = ID;
Public String GetName () {return name;
public void SetName (String name) {this.name = name;
Public Set getstudents () {return students;
The public void setstudents (Set students) {this.students = students;
} public class Student {private int id;
private String name;
public int getId () {return id;
The public void setId (int id) {this.id = ID;
Public String GetName () {return name;
public void SetName (String name) {this.name = name; }
}
Comparing a One-to-many association mapping with a many-to-many correlation mapping we've talked about earlier, we can see that the two mapping principles are consistent, with a foreign key added to one end of the multiple. The difference is that the relationship between the maintenance is different, more on one maintenance is more point to one of the relationship, with this relationship, in the loading time can be a load up, a one-to-many maintenance is a point of many relations, with this relationship, in the loading of a time can be more load up.