Initialization of the 1.Hibernate.
Read Hibernate configuration information-〉 Create session Factory
1 Create an instance of the Configeration class.
How it is constructed: reads the configuration information (Hibernate config.xml) into memory.
A Configeration instance represents a collection of all Java classes to the SQL database map hibernate.
2) Create Sessionfactory instance
Copies all configuration information from the Configeration object to the Sessionfactory cache.
The Sessionfactory instance represents a database storage source, and is no longer associated with the Configeration object after it is created.
Cache: A property of a Java object (usually a property of some collection type) that occupies memory space.
Sessionfactory Cache: Hibernate configuration information. or map metadata.
Cache-Large: Heavyweight object small: Lightweight object
3 The method of calling Sessionfactory to create a session
1 "The user provides the JDBC connection on its own.
Connection con=datasource.getconnection ();
Session s=sessionfactory.opensession (Con);
2 "Let Sessionfactory provide connection
Session s=sessionfactory.opensession ();
4 to manipulate database access through a variety of methods provided by the session interface.
Hibernate Caching System
First-level caching:
The session has a built-in cache that holds objects that are loaded by the current unit of work.
Each session has its own separate cache and can only be accessed by the current unit of work.