Hibernate framework is very useful, the first sense is that in your configuration, it can automatically help you encapsulate the entity, you can also automatically encapsulate another entity within the entity you specify
Here is a little research (the following fields must have the Set/get method)
First, take a look at my main entity class employee employee and department relationship is Many-to-one
The Hbm.xml configuration file for employee is as follows-----
First line: Name represents the Department field, class is self-evident
The third line: column refers to the name of the row in the employee table
We write with the Department class, the employee corresponds to a department, and department corresponds to multiple employee
Department entity class, so write set<employee> empset field
Department.hbm.xml
Second line: Empset corresponds to the field value of this entity
Row five: The column name corresponding to the foreign key
Line seventh: entities that correspond to multiple parties
-----------------------------------------------------------
One-to-one relationship employee and Check_card (employee card)
Check_card.java
Add the following in Employee.hbm.xml
And in Check_Card.hbm.xml add the following------------many-to-one is an exception
------------------------------------------------------------------------------------------
Since the connection, then take the department entity as an example, because the department has a number of sub-departments, and a parent department-----Department entity class on top
Here's a look at its hbm.xml file, the same code as before. That's not much to say.
Next, let's just say that the above fetch and lazy are the default values written above
Fetch crawl strategy is divided into select and join
Join-----After you get an entity, the data associated with it is encapsulated together
Lazy-----You can use lazy only if fetch is a SELECT, and you won't be able to crawl it when you don't have the relevant data