Previous article hibernate from getting started to mastering (ix) A pair of multiple bidirectional association mappings we explained the relevant content of a one-to-many correlation mapping, this time we continue to multiple one-way association mappings.
Multi-pair multiple one-way association mappings
Before explaining the multiple to multiple one-way association mapping, first look at the relevant class diagram and code, as follows:
public class Role {
private int id;
private String name;
public int getId () {return
ID;
}
public void setId (int id) {
this.id = ID;
}
Public String GetName () {return
name;
}
public void SetName (String name) {
this.name = name;
}
}
public class User {
private int id;
private String name;
private Set roles;
public int getId () {return
ID;
}
public void setId (int id) {
this.id = ID;
}
Public String GetName () {return
name;
}
public void SetName (String name) {
this.name = name;
}
Public Set GetRoles () {return
roles;
}
public void Setroles (Set roles) {
this.roles = roles;
}
}