1.JPA
JPA Full Name: Java persistence API
JPA describes the mapping of objects-relational tables through JDK 5.0 annotations or XML, and persists entity objects for the run-time into the database.
The advent of JPA?
There are two reasons for JPA to occur:
One is to simplify the development of object persistence for existing Java EE and Java SE applications;
Second, Sun wants to integrate the ORM technology to achieve consistency in the field of persistence.
Technology provided by 1.1.JPA
(1) ORM Mapping Meta Data
JPA supports XML and JDK 5.0 annotations in the form of two metadata that describes the mapping between an object and a table, and the framework thus holds the entity object
to the database table;
(2) JPA's API
Used to manipulate entity objects, perform crud operations, and the framework does everything for us in the background, and developers can solve them from tedious JDBC and SQL code.
Take it off.
(3) Query Language
Query the data by object-oriented rather than database-oriented query language, and avoid tightly coupling the SQL statements of the program.
2. Hibernate
JPA is a strong one in JPA provider, which requires provider to function. Functionally, JPA is now a subset of hibernate functionality. Hibernate starts at 3.2 and is compatible with JPA. Hibernate3.2 obtained the JPA (Java persistence API) Compatibility certificate for Sun TCK.
For example:
(1) The state of the entity object, in Hibernate there are free, persistent, free three species, JPA has new,managed,detached,removed, and these states are one by one corresponding.
(2) Flush method, all corresponding,
(3) Query query = manager.createquery (SQL), which is the session in Hibernate and becomes the manager in JPA
3. The relationship between JPA and hibernate can simply be understood as JPA is the standard interface, hibernate is the implementation.
So how does hibernate achieve this relationship with JPA?
Hibernate is mainly achieved through three components, and hibernate-annotation, Hibernate-entitymanager and Hibernate-core.
(1) Hibernate-annotation is the basis for hibernate to support annotation mode configuration, which includes the standard JPA annotation and the annotation of Hibernate's own special features.
(2) Hibernate-core is the core implementation of Hibernate and provides all the core functions of hibernate.
(3) Hibernate-entitymanager implements the standard JPA, which can be seen as an adapter between Hibernate-core and JPA, which does not directly provide ORM functionality, but rather encapsulates the hibernate-core. Make hibernate conform to JPA specifications.
In general, JPA is the norm, Hibernate is the framework, JPA is the persistence specification, and Hibernate implements JPA.
The relationship between JPA and hibernate