Framework summary of Hibernate (1) Overview of Hibernate

Hibernate overview

        In today's mainstream persistence layer framework, hibernate framework is the leader among many frameworks. It is an open source ORM framework that encapsulates JDBC with lightweight objects, so that Java developers can use object-oriented programming ideas to perform database operations.
        To understand the hibernate framework, you need to introduce a concept, the concept of ORM. The so-called ORM is Object Relational Mapping (Object Relational Mapping). This mode is a technology to solve the mismatch between object-oriented and relational databases. Simply put, it is for the entity classes and database tables in our program. Establish a corresponding relationship. An ORM automatically persists objects in a program to a relational database by using metadata that describes the mapping between objects and the database. ORM provides a way to achieve persistence, which is to use mapping metadata to describe the mapping of object relationships, so that ORM middleware can act as a bridge between the business logic layer and the database layer of each application. And Hibernate is one of the typical Java ORM middleware.
        There is another concept that needs to be understood here, which is persistence, Persistence. The following is the introduction in Hibernate's official website http://hibernate.org :
        
    
        According to the introduction, persistence simply means that we want the data in our application to survive longer than our application process. In Java terminology, we want the state of our (some) objects to exist outside the scope of the JVM, so that the state of the same object can be used later.
      Therefore, we can speculate that in the concept of ORM, a persistent class corresponds to a table in the database, each instance of the class corresponds to a record in the table corresponding to the database, and each attribute of the class corresponds to a table in the database table. each field.
       In addition, the SQL code generated by ORM is generally not very efficient, and the efficiency will decrease for multi-table or complex table operations. In addition, when persisting objects, ORM generally persists all attributes, which also reduces system performance.
        Although ORM has certain inconveniences, the flaws do not hide the flaws. Since ORM still has an irreplaceable role compared to other methods, the ORM idea is still used in the hibernate framework.
        Hibernate is an open source, lightweight persistence layer framework that implements the ORM idea internally and encapsulates JDBC operations internally. The so-called lightweight means that it consumes less resources; the realization of the ORM idea means that the focus of development programmers is no longer restricted to the writing of SQL statements.

        

        

Introduction to the core of Hibernate

          The core of Hibernate is shown in the figure:
    
           

            As can be seen from the figure, the core of Hibernate consists of two major configuration files and six interfaces, which are:
               hibernate.config.xml: core configuration file
                xxx.hbm.xml: mapping file
                Configuration interface: responsible for configuring and starting Hibernate
                SessionFactory interface: responsible for initializing Hibernate
                Transaction interface: responsible for transactions
                Query interface and Criteria interface: responsible for executing various database queries


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324771825&siteId=291194637