Hibernate knowledge point summary
The learning of Hibernate is the longest in the entire SSH learning process, because there are many things involved in it. This blog will briefly introduce the preliminary summary of Hibernate by myself.
1. Graphic Display
2. Graph Analysis
Hibernate definition: Hibernate is an open-source object relationship ing framework that encapsulates JDBC objects in a very lightweight manner, so that Java programmers can use the object programming thinking to manipulate the database as they wish.
Hibernate understood by xiaobian is divided into three parts: one is the configuration of the xml part, the other is the Hibernate-related api, and the last is the specific addition, deletion, modification, and query operations.
1. xml configuration
The xml involved in hibernate consists of two parts:
① Relationship ing configuration file xxx. hbm. xml in the description class and table
This section mainly describes the ing between object classes and tables in the database. I divided the ing between object classes and tables into two parts, it mainly describes the correspondence between its own attributes and fields in the data table, and the cascading relationship, for example, one-to-one, one-to-many, and multiple-to-peer relationship Descriptions between entities. After configuration, the database generates corresponding foreign key constraints based on the configured cascading relationship.
② Description of the configuration file hibernate. cfg. xml for connecting to the database
This section mainly records the necessary information for connecting to the database, such as the database driver, database name, username and password, and the dialect configuration required for accessing different databases through Hibernate. hbm. xml file introduction. It is the core configuration file of hibernate.
2. Hibernate API
Applications can access the database directly through the Hibernate API. Apis in the Hibernate API can be divided into the following types.
① Provide interfaces for database access operations (such as saving, updating, deleting, and querying objects. These interfaces include Session, Transaction, and Query Interfaces.
② Interfaces used to configure Hibernate: Configuration, Hibernate Configuration, Hibernate startup, and SessionFactory object creation;
Initialize the Hibernate interface: SessionFactory. initialize Hibernate. When the data storage source proxy, create a Session object.
③ The callback interface allows the application to accept events that occur inside Hibernate and respond accordingly. These interfaces include Interceptor, Lifecycle, and Validatable.
④ Interfaces used to expand Hibernate functions, such as UserType, CompositeUserType, and IdentifierGenerator interfaces. Applications can extend these interfaces if needed.
Hibernate encapsulates JDBC, JTA (JavaTransaction API), and JNDI (Java Naming and Directory Interface ). JDBC provides underlying data access operations. As long as you provide the corresponding JDBC driver, Hibernate can access any database system. JNDI and JTA enable Hibernate to integrate with the J2EE application server.
3. Object operations
The addition, deletion, modification, and query operations of objects in Hibernate depend on the Hibernate API functions to operate on databases. This section is also divided into two parts, one is the addition, deletion, modification, and query operations of the class itself, and the other is the addition, deletion, and query operations associated with other classes. However, you can use the encapsulation provided by Hibernate to complete object operations with low performance. You can modify parameters in the ing configuration file between classes and tables to improve the operational performance of Hibernate.
The above is your preliminary learning Summary of Hibenate. You are welcome to exchange and learn.