1. Concept
Hibernate is an open source object-relational mapping framework that provides JDBC with a very lightweight object encapsulation that maps Pojo to database tables, is a fully automated ORM framework, and Hibernate can automatically generate SQL statements Automatic execution allows Java programmers to manipulate the database using object programming thinking at will.
Hibernate objects:
①configuration (an instance of the configuration class first locates the location of the mapped document, reads the configuration, and then creates a Sessionfactory object)
②sessionfactory (a database corresponds to a Sessionfactory object)
③session (for objects that manipulate the database)
The ④transition (Transaction interface is an abstraction of the actual transaction implementation that includes JDBC transactions, usertransaction in JTA, and even CORBA transactions)
The ⑤query (query interface makes it easy to query the database and persistent objects, which can be expressed in two ways: the HQL language or the SQL statement for the local database.
The ⑥criteria interface is very similar to the query interface, allowing you to create and execute object-oriented, standardized queries. It is important to note that the criteria interface is also lightweight and cannot be used outside the session.
Through these interfaces, you can not only access persistent objects, but also enable transaction control.
Code implementation:
16.spring+hibernate Simple Example