Last Post hibernate from getting started to mastering (eight) One-to-many one-way correlation mapping, we explained a pair of multiple one-way mapping of the relevant content, this time we explain a pair of multiple two-way mapping related content.
One-to-many Two-Way Association mappings
One-to-many Two-Way association mappings, a set object that exists at one end of one side and one end of the other at a multiple end, thus guaranteeing that a two-way association is guaranteed to be loaded on one end or more of the end of the load.
Similarities and differences of One-to-many two-way correlation mapping and one-to-many unidirectional correlation mapping
A one-to-many two-way association maps the 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;
Private Classes Classes;
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 Classes getclasses () {return Classes;public void setclasses (Classes Classes) {this.classes = Classes; }
}