Hibernate from entry to Mastery (11) Multi-pair multi-directional correlation mapping

Source: Internet
Author: User

Last time we were in hibernate from getting started to mastering (10) Multi-directional and multiple one-way association mapping to explain the multiple to multiple one-way association mapping, this time we explain the last of the seven mappings in a Many-to-many bidirectional association mapping.

Multi-pair multi-directional correlation mapping

According to our previous practice, first look at the relevant class diagram and code, as follows:

public class Role {private int id;      
    private String name;  
          
    Private Set users;  
    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 Getusers () {return users;  
    public void Setusers (Set users) {this.users = users;       
    The public class User {private int id;  
    private String name;  
          
    private Set roles;  
    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 GetRoles () {return roles; public void Setroles (Set roles) {this.roles = roles; }  
}

Next, we compare the previous blog hibernate from Getting Started to mastering (10) Multiple to multiple one-way correlation mapping in multi-directional and multiple one-way correlation mapping, to analyze the multiple bidirectional correlation mapping, and to realize the difference and connection between them.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.