Hibernate from entry to Mastery (vii) multiple to one one-way association mapping

Source: Internet
Author: User

Last Post hibernate from getting started to mastering (vi) One-to-one Bidirectional Association mapping we introduced a one-to-one bidirectional association mapping, and this blog post we'll explain a many-to-many correlation mapping

Multi-pair One-way association mapping

A many-to-many correlation mapping is similar to a one-to-one correlation mapping, except that multiple objects can exist on the pointing end of the Many-to-many one, while loading the pointed end at the point of loading.

The similarities and differences between multiple pairs and one-on-one

Comparing one-to-one one-way association mappings with multiple pairs of one-way association mappings, the similarities are that when the pointing end is loaded, the pointing end is loaded together, as seen from the structure diagram and code in the following class. (Here are only a pair of related illustrations and code, one-to-one illustrations and code references before the article hibernate from getting started to mastering (v) One-to-one one-way association mapping)

public class Group {  
    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 group group;  
    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 Group Getgroup () {return  
        group;  
    }  
    public void Setgroup (group group) {  
        this.group = group;  
    }  
}

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.