The average person does know that lazy is used to control the delayed loading and loading immediately, without considering why it is used.
In hibernate3.0, lazy has three values: True, false, and proxy. The default value is lazy = "proxy ".
The specific setting depends on your needs. It doesn't mean that the setting is the best.
Suppose that the student object contains a head object
If you are sure you want to use the attributes in the head object when using the student object, you can set to load immediately, because it is set to load immediately, the head of student will be queried at the same time as the student is queried, and hibernate will associate two tables during the query to generate only one SQL statement. If you set delayed loading, one or more SQL statements will be generated: "1" is the statement used to query student, "N" is to query n statements of the head based on N student IDs. In addition, delayed loading is used to execute the query. In this way, the system determines that loading is required, and loading is not required or takes time. The performance is definitely better than loading immediately!
If you need to use the head attribute only when student is used, you can set it to delayed loading, because it is certainly more expensive to query the data of two tables than to query one table.
It depends on your actual needs.