JPA

JPA first appeared in 2006 (the latest version, 2.2, was released in 2013, and sometimes it is called JPA2), and it aims to describe relational data management in Java applications. Nowadays, JPA is a standard that defines how applications organize a persistence layer. It consists of the API itself and Java Persistence Query Language (JPQL). JPQL is an SQL-like platform-independent language that queries JPA entity objects through repositories instead of databases.

In contrast with JDBC, which is a standard for database access, JPA is a standard for Object Relational Mapping (ORM), which allows mapping objects in code to tables in a database. ORM usually uses JDBC and on-flight generated SQL queries under the hood, but this mechanic is mostly hidden from application developers. JPA allows mapping not only entities but also entity relationships in order to easily load associated objects. 

The most used JPA implementations are Hibernate (http://hibernate.org) and EclipseLink (http://www.eclipse.org/eclipselink). Both of these implement JPA 2.2 and are interchangeable. As well as implementing the JPA standard, both projects propose an additional set of features that are not defined in the specification but may be handy in some cases. For example, EclipseLink makes it possible to handle database change events and describe the mapping of entities to tables in multiple databases. On the other hand, Hibernate proposes better support for timestamps and natural IDs. Both libraries support multi-tenancy. However, we should understand that when using exclusive features, these libraries stop being interchangeable.

Another reason to use JPA implementation instead of pure JDBC is due to the caching features provided by Hibernate and EclipseLink. Both libraries allow us to minimize the number of actual database requests caching entities in a first-level session cache, or even in a second-level external cache. This feature alone may have a notable impact on application performance.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.196.146