Hibernate learning notes

< p class = "L" > transferred from < a style = "font size: 14px;" href="%20http://blog.csdn.net/jiuqiyuliang/article/details/39078749%20"& gt; [SSH advanced path] basic principles of Hibernate (I)

Hibernate encapsulates the database, so that programmers can directly operate objects without writing specific database operations.

The function of ORM (object relation mapping) is to make a mapping between relational database and objects. From object to relation, and then from relation to object. In this way, we don't need to deal with complex SQL when operating the database, as long as we operate it like operating objects (map the fields of the relational database into the attributes of the object in memory).

Hibernate is an open source ORM framework. It encapsulates JDBC with very lightweight objects. It establishes a mapping relationship between POJO and database tables. It is a fully automatic ORM framework. Hibernate can automatically generate and execute SQL statements, so that Java programmers can manipulate the database with object programming thinking at will.

The core of Hibernate:

From the above figure, we can see the six core interfaces of hibernate, the two main configuration files, and their direct relationship. Everything about hibernate is here. Let's have a brief understanding from top to bottom and summarize each interface in one sentence.

1. Configuration interface: responsible for configuring and starting hibernate

2. Sessionfactory interface: responsible for initializing hibernate

3. Session interface: responsible for crud operation of persistent objects

4. Transaction interface: responsible for transaction

5. Query interface and criteria interface: responsible for executing various database queries

Note: the configuration instance is an object during startup. Once the sessionfactory is created, it will be discarded.

single table mapping in Hibernate

First, build a hibernate cfg. XML file

Write a student class

Entity classes correspond to tables in database

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>