Hibernate introduction

HibernateIt is a high-performance object relational persistent storage and query service.

1. What is Hibernate?

1、Hibernateconcept

HibernateIt is the framework of data access layer and encapsulates JDBC. It is an object-oriented solution for data access.

2、HibernateRole

Hibernate can directly access objects, and Hibernate automatically converts this access to SQL execution, thus achieving the purpose of indirect access to the database and simplifying the data access layer code.

Two, why use Hibernate?

1、HibernateComparison with JDBC

1)The use of JDBC has the following disadvantages:

-A large number of SQL statements need to be written.

-Need to give a lot of “?” parameter assignment

-ResultSet result sets need to be transformed into entity objects.

-SQLContains unique functions that can not be transplanted

Using Hibernate can solve the above problems.

-Automatic generation of SQL statement

-Automatically give “?” parameter assignment

-Automatically converts the ResultSet result set to the entity object.

-Adopt a consistent approach to database operation with good portability.

2、HibernateComparison with MyBatis

1)Common characteristics

-The JDBC is encapsulated.

-The problem of mapping between entity and database is solved by using ORM thought.

2)MyBatis

-MyBatisUsing SQL and entity mapping, the degree of encapsulation of JDBC is lighter.

-MyBatisWriting SQL is more flexible.

3)Hibernate

-HibernateUsing database and entity mapping, the degree of encapsulation of JDBC is heavier.

-HibernateAutomatic generation of SQL is more efficient for basic operations.

 

Leave a Reply

Your email address will not be published. Required fields are marked *