JPA uses JDK 5.0 annotations or XML to describe the mapping relationships of object-relational tables and to persist the entity objects of the runtime to the database.
Origin
Sun introduced the new JPA ORM specification for two reasons: first, simplifying the development of object persistence for existing Java EE and Java SE applications; second, Sun wants to integrate the ORM technology to achieve the world.
JPA is developed by the EJB 3.0 software Expert Group as part of the JSR-220 implementation. But it's not confined to EJB 3.0, and you can use it in Web apps and even desktop applications. JPA's purpose is to provide POJO standard specification, this shows that after years of practical exploration, can be separated from the container operation, easy to develop and test the concept has been deeply rooted. Currently hibernate 3.2, TopLink 10.1.3 and OPENJPA provide JPA implementations.
JPA's overall thinking is broadly consistent with the existing ORM frameworks such as Hibernate, Toplink,jdo, and so on. In general, JPA includes the following 3 areas of technology:
ORM Map Meta Data
JPA supports the form of XML and JDK 5.0 annotations, which describe the mapping relationship between objects and tables, in which the entity objects are persisted to the database table;
The JPA API
Used to manipulate entity objects, perform crud operations, and the framework completes everything for us in the background, freeing developers from cumbersome JDBC and SQL code.
Query Language
This is a very important aspect of the persistence operation, by querying the data by object-oriented rather than database-oriented query language, avoiding the tight coupling of the program's SQL statements.
The advantages of JPA
1 standardization
JPA is one of the Java EE standards published by the JCP organization, so any framework that claims to conform to JPA standards follows the same architecture and provides the same access APIs, which ensures that enterprise applications based on JPA development can be run in a different JPA framework with minimal modification.
2 support for container-level features
The JPA framework supports container-level transactions such as large datasets, transactions, and concurrency, which enables JPA to transcend the limitations of the simple persistence framework and play a greater role in enterprise applications.
3 easy to use, easy to integrate
One of the main goals of JPA is to provide a simpler programming model: creating entities under the JPA framework is as simple as creating Java classes without any constraints or restrictions, just using Javax.persistence.Entity, the JPA framework and interfaces are also very simple, not too many special rules and design pattern requirements, developers can easily grasp. JPA is designed based on non-intrusive principles, so it can be easily integrated with other frameworks or containers.
4 query capabilities comparable to JDBC
The query language of JPA is object-oriented rather than database oriented, it constructs query statement with object-oriented natural syntax, which can be regarded as the equivalent of Hibernate hql. JPA defines a unique JPQL (Java persistence query Language), JPQL is an extension of the EJB QL, a query language for entities that operate on entities rather than tables of relational databases, and can support batch updates and modifications, JOIN, GROUP by, have, and so on are usually only the advanced query features that SQL can provide, and even the ability to support subqueries.