Hibernate one-to-many mapping relationship

Source: Internet
Author: User
Tags set set
In the CRM system, a customer has multiple contacts, and a contact corresponds to multiple customers.

Requirements: Save a contact and save a customer

Analysis:
Table relationships

SQL statements

Entity class
More than one contact for a single customer

One customer corresponds to multiple contacts

Why choose the Set method
Set set features: Do not repeat the following 0 for the purpose of not occupying space

Note that when the ToString is not associated with the object to come out, because the Linkman ToString called the customer's ToString so that the cycle of death

mapping files
Multiple contacts for one customer

Because a table's primary key can be used as a foreign key for another table, there is no need to describe which property in the customer corresponds to the foreign key in the Linkman

One customer corresponds to multiple contacts

Hibernate one-to-many mapping relationship

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.