in my opinion ,Hibernate Provide these mapping relationships , Common is one to one and many to one , And try not to use the join table when you don't need it . Many to many will use , If used , We should first consider whether the underlying database design is reasonable .
 
In actual development , stay Hibernate There is often another alternative to the relationship , Each table acts as a single table mapping , Business logic controls foreign key relationships ( Sometimes it's just an associated column , But it doesn't have to be a foreign key constraint ), It's more flexible , And the integrity of the data is also guaranteed .
 
Of course ,“ Single table mapping , Business controls foreign key relationships ” Is not to say that Hibernate The entity association function of is redundant ,Hibernate There are many advantages of entity Association , Any book is about advantages , Well used will make developers feel more convenient , Now I also use the two schemes together . For example, for two uncertain entities , Single table association is often used .
 
I used to be a beginner Hibernate Before we fully understand these connections , It's a single table mapping , Business control foreign key relations do , Found no problems , The program also works well .
 
See if these are regret wasting time learning mapping relationship ? ha-ha ,Hibernate Of OR Mapping yes Hibernate Soul , I Believe Hibernate The founder of the company has a deeper understanding than most of us . Only by learning these can we realize Hibernate The idea of the designer . Learn something , Not just writing your own code , You should be able to read other people's code . Therefore, it is necessary to learn these association maps systematically .
 
All of the above are my own views . Welcome to exchange and discuss here .
 
Hibernate In actual project development ,hbm.xml Including database scripts are all through Xdoclet Generated , It is not used here Xdoclet The goal is to make it easy to understand these mapping models . Entity - Data sheet - The mapping file Compare the three , It's so intuitive .
 
I dozed off , Let's write here for the moment , If you have a new idea, add it ....
 
-----------------------------------------------------
 
Hibernate Association mapping directory
│ 
├─ One way Association
│  ├─   One to one foreign key one-way Association │  ├─   One to one primary key one-way Association
│  ├─   One to one connection form to Association │  ├─   One to many foreign key one-way Association
│  ├─   One to many join forms to associate
│  ├─   Many to one foreign key one-way Association
│  ├─   Many to one links form to Association
│  └─   Many to many one-way Association
└─ Two way connection
    ├─   One to one foreign key bidirectional association
    ├─   One to one primary key bidirectional association     ├─   One to one connection table bidirectional association
    ├─   One to many foreign key bidirectional association
    ├─   One to many join table bidirectional association
    └─   Many to many bidirectional association

Hibernate Entity association mapping ---- Summarize more related articles

  1. Hibernate Entity association mapping 【 turn 】

    Hibernate Association mapping directory │ ├─ One way Association │  ├─   One to one foreign key one-way Association │  ├─   One to one primary key one-way Association │  ├─   One to one connection form to Association │  ├─   One to many foreign key one-way Association │  ├─   One to many ...

  2. Hibernate Entity association mapping ( Reprint )

    Original link address :http://lavasoft.blog.51cto.com/62575/39398/ Hibernate:Hibernate Quick query of mapping instance of association relationship   Hibernate Association mapping directory ...

  3. Hibernate The mapping of the relation between the two ( One to one primary key mapping and one to one foreign key mapping )

    1:Hibernate One to one foreign key mapping of association relation mapping of : 1.1: First, introduce the package , Omit 1.2: Second, create entity classes : The relationship between user information and ID card information is used here , The user's primary key number can be used as the primary key of ID card information and ID card letter ...

  4. Java IDE Editor --- IntelliJ IDEA Advanced Generate hibernate Entities and mapping files

    original text : turn :Java IDE Editor --- IntelliJ IDEA Advanced Generate hibernate Entities and mapping files 2011-04-30 12:50 A lot of people don't know how to use it  IntelliJ IDE ...

  5. hibernate Entity relation mapping notes

    @ Property descriptions are often used :     @Entity: Entity class     @Table: Specify the corresponding data table     @Id: Primary key , Use can be null The type of value , Assuming that the entity class is not saved to the database is a transient state     @Col ...

  6. Framework hibernate The mapping of the relation between the two

    Case study : complete CRM How to save the contact of Demand analysis 1. Because customers and contacts are one to many , In the case of customers , Complete the operation of adding and saving contacts Technical analysis Hibernate One to many mapping of association relation of ( a key ) 1. J ...

  7. Hibernate The mapping of association relation in the database

    Technical analysis Hibernate One to many mapping of association relation of ( a key )        1. JavaWEB The design of one to many and its table building principle         2. First import SQL Create table statement of                  ...

  8. Hibernate The mapping of the relation between the two ( One to many and many to one mappings , Many to many mapping )

    ~~~ And then what happened before Hibernate Frame and learn ( After the last interview, I found that I really need to learn the framework , Or you'll be fooled into training .)~~~ 1:Hibernate Association mapping of , There are one to many and many to one mappings , Many to many mapping : 1.1: ...

  9. Hibernate Study --- Association mapping

    Association is one of the most used relationships , It's very important , Reflected in memory as entity relationships , Mapping to DB In the primary key foreign key relations , Relationships between entities , That is, the maintenance of external keys , The occurrence of connections , That is, the change of external key data . I will not repeat what is a foreign key and what is a primary key here . ...

Random recommendation

  1. Git API Tutorial

    summary It's about explaining what git Before , We need version control (Version Control) Make a basic overview , In general , Our source code is managed and maintained in two dimensions of time and space , The code itself and the project file that organizes the code ( ...

  2. IE10,IE11 Next cookie Unable to write problem

    asp.net 4.0 The program , After the release of , Test in ie6,ie7,ie8,ie9 You can log in normally , But in ie10,ie11 I just can't save it cookie, I checked whether ie10,ie11 Whether there is a setting problem is not ...

  3. carpenter ing[ Indexes ]

    There were clouds in ancient times. , A carpenter who can't write code is not a good cook . In response to this call , Start my woodworking career . First, introduce a website ,www.zuojiaju.com Woodworking enthusiasts , There are lots of posts about carpenters , Thank you . Just before ...

  4. MINUS,INTERSECT,UNION elementary analysis

    Reprint :http://blog.csdn.net/gan690416372/article/details/5012397 SQL Three keywords in a statement :MINUS( subtract ),INTERSECT( intersection ) and UN ...

  5. Codeforces Round #411 (Div. 1) D. Expected diameter of a tree

    The main idea of the topic : Give a forest , Give out... Every time you ask u,v, Ask from u Randomly select a point in the connected block and v Randomly select a point in the connected block to connect , The diameter of the connected tree is expected to be ( Not tree output -1).(n,q<=10^5) solution : Preprocessing out the connected ...

  6. python to update tomcat Script

    #!/usr/bin/env python# _*_ coding:UTF-8 _*_import commandsimport time,os,sysfrom download_bag import ...

  7. &lt; Record &gt; PHP Buffer zone ob

    Introduce : ob yes output buffering For short , Output buffer , The buffer is through php.ini Medium output_buffering Variable controlled . The default value is off, It can be set to on Open up buffer. come to attack bu ...

  8. php Paging implementation and php How to handle large file upload failure

    1. php Pagination : If you want to do it php paging , First of all, we need to find out what kind of pagination we want , Which parameters are involved , How do parameters relate to each other : The target paging effect is as follows : analysis : 1. There are two main parameters involved : One is the page number of the current output page , With variable $p  Express , another ...

  9. php Output a lot of code ( With variables and methods )

    echo<<<EOF <html> <body> <formname="MainForm"method="post&quo ...

  10. First time to know Docker And installation

    What is? Docker Docker The idea is to achieve “Build,Ship and Run Any App,Anywhere”, That is, through the encapsulation of the application (Packaging). distribution (Distribution). Ministry ...