Reference: Java Web core Framework
http://blog.csdn.net/lsh6688/article/details/7611950
Part 1.hibernate Core interface hierarchy schema relationship
Figure: Hibernate core Interface Hierarchy schema relationship
, hibernate interfaces can be broadly divided into the following types:
1. Basic Operation class : some interfaces that are called by the user's application to complete basic creation, read, update, delete operations, and query operations. These interfaces are the primary interface for hibernate to implement the business logic of the user program, which includes session, transaction, and query.
2. Configuration class : Hibernate is used to read the interface of a configuration file such as a mapping table, which typically represents a config class.
3. Callback (Callback) interface : It allows the application to take action on the occurrence of some events, such as Interceptor, lifecycle, and validatable, which are the same type of interface.
4. Some interfaces that can be used to extend Hibernate's mapping mechanism : For example, usertype, Compositeusertype, and Identifiergenerator. These interfaces can be implemented by the user program (if necessary).
Hibernate uses the following techniques in the Java EE architecture: JDBC, JTA, JNDI. Where JDBC is a basic layer that supports relational database operations, it is combined with jndi and JTA to make hibernate easy to integrate into the Java EE Application Server.
Part 2. Common Core interfaces and interrelationships
There are 6 Common Core interfaces: Session, Sessionfactory, Configuration, Transaction, Query, Criteria
Diagram: interface class generation relationship
Session Interface:
The session interface session interface is one of the most important interfaces for hibernate developers. In hibernate, however, the instantiated session is a lightweight class, and creating and destroying it does not consume a lot of resources. This is really important in the actual project, because in the client program, the session object may be created and destroyed continuously, if the session overhead is too large, it will adversely affect the system. But the session object is non-thread safe, so in your design it is better to have a thread that creates only one session object . Session can be seen as a middle interface between data connection and transaction management. We can think of the session as a buffer of persistent objects, hibernate detects changes to these persistent objects, and refreshes the database in a timely manner. We sometimes call the session a persistent Layer manager because it contains some persistent layer-related operations, such as storing persistent objects to the database, and getting them from the database. It is important to note that Hibernate's session differs from the HttpSession in JSP applications. When we use the term session, we refer to the session in Hibernate, and we will later call the Httpsesion object the user session.
Sessionfactory Interface:
The Sessionfactroy interface is responsible for initializing hibernate. It acts as a proxy for the data storage source and is responsible for creating session objects. The factory model is used here. It is important to note that Sessionfactory is not lightweight, because in general, a project typically requires only one sessionfactory, and when you need to manipulate multiple databases, you can specify a sessionfactory for each database.
Transaction interface:
The transaction interface is responsible for transaction-related operations, usually appearing in hibernate additions and deletions, but people using hibernate generally use spring to manage transactions.
Query and Criteria Interface:
The query and criteria interfaces are responsible for executing various database queries. It can be expressed in either the HQL language or the SQL statement. Its return value is generally list. Need to convert yourself.
Configuration Interface:
The configuration object is used to configure and start hibernate. Hibernate applications use configuration instances to specify the location of the object-relational map file or dynamically configure Hibernate properties, and then create the Sessionfactory instance. During Hibernate startup, an instance of the configuration class first locates the map document location, reads the configuration, and then creates the Sessionfactory instance. We can view the source code of the configuration, and its configure () method is implemented like this:
Public Configuration Configure () throwshibernateexception { Configure ("/hibernate.cfg.xml"); the location of the ORM file is specified here returnthis;
Hibernate learning Notes-core programming