Java Persistence API (English)

Z FI WIKI
Přejít na: navigace, hledání
Tato stránka je dostupná také v češtině: Java Persistence API

Java Persistence API is an Application Programming Interface which simplifies the entity persistence model[1]. It was introduced with EJB version 3.0 and most recent version is JavaTM Persistence 2.0 (http://jcp.org/en/jsr/detail?id=317) specified by JSR 317 in winter 2009 [2].

In comparison with the previous technology EJB 2.1, JPA provides these benefits[1]:

  • Requires fewer classes and interfaces
  • Virtually eliminates lengthy deployment descriptors through annotations
  • Addresses most typical specifications through annotation defaults
  • Provides cleaner, easier, standardized object-relational mapping
  • Eliminates the need for lookup code
  • Adds support for inheritance, polymorphism and polymorphic queries
  • Adds support for named (static) and dynamic queries.
  • Provides a Java Persistence query language (JPQL)
  • Makes it easier to test entities outside of the EJB container
  • Can be used outside of the container
  • Can be used with pluggable, third-party persistence providers ( Hibernate, Oracle Toplink ...)

Other benefits of using JPA include usage of POJO entities and a lot of high quality documentation. Using JPA also bears some disadvantages i.e. necessity of JPQL knowledge or inefficiency when developing small applications which will run only on one type of database.

An alternative to this technology is provided by JDO currently under development of Apache Foundation.


References

[1] Rahul Biswas. The java persistence api - a simpler programming model for entity persistence. http://www.oracle.com/technetwork/articles/javaee/jpa-137156.html, May 2006.

[2] Sun Microsystems. Jsr 317: Javatm persistence 2.0. http://jcp.org/en/jsr/detail?id=317, 2010.