Hibernate from entry to Mastery (ix) one-to-many bidirectional correlation mapping

Source: Internet
Author: User

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; }  
}

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.