Readers should note: Hibernate version is different, the operating mechanism is not the same, the following is hibernate3.x as a guide
Get method:
Hibernate confirms the existence of the data for that ID, first in the session cache, then in the level two cache, without querying the database and returning NULL in the database.
Conclusion: For the Get method, hibernate must obtain the actual data, otherwise return null
Load method:
Based on the configuration of the lazy attribute at the class level on the mapping file (true by default), it is discussed in detail;
If true, first look in the session cache to see if the ID corresponds to the existence of the object, does not exist then use lazy loading, return the entity's proxy class object (the proxy class is a subclass of the entity class, generated dynamically by Cglib).
Wait until the specific use of the object (in addition to the OID) to query the level two cache and database, if you still do not find a qualifying record, will throw a objectnotfoundexception.
If False, it is the same as the Get method lookup order, except that a objectnotfoundexception will be thrown if the qualifying record is not found.
Conclusion: The Load method believes that the data in the database must exist, can be assured that the use of agents to delay loading, if the use of problems found in the process, can only throw exceptions
Hibernate get method differs from Load method