请输入您要查询的百科知识:

 

词条 Java Persistence API
释义

  1. History

  2. Entities

  3. The Java Persistence Query Language

  4. Motivation

  5. Related technologies

      Enterprise JavaBeans    Java Data Objects API    Service Data Object API    Hibernate    Spring Data JPA[11]  

  6. JPA 2.0

  7. JPA 2.1

  8. JPA 2.2

  9. JPA Future Work

  10. Tools

  11. See also

  12. References

  13. External links

     General info  Tutorials 
{{refimprove|date=June 2010}}

The Java Persistence API (JPA) is a Java application programming interface specification that describes the management of relational data in applications using Java Platform, Standard Edition and Java Platform, Enterprise Edition.

Persistence in this context covers three areas:

  • the API itself, defined in the javax.persistence package
  • the Java Persistence Query Language (JPQL)
  • object/relational metadata

The reference implementation for JPA is EclipseLink.

History

The final release date of the JPA 1.0 specification was 11 May 2006 as part of Java Community Process JSR 220. The JPA 2.0 specification was released 10 December 2009 (The Java EE 6 platform requires JPA 2.0[1].) The JPA 2.1 specification was released 22 April 2013 (The Java EE 7 platform requires JPA 2.1[2].)

Entities

A persistence entity is a lightweight Java class whose state is typically persisted to a table in a relational database. Instances of such an entity correspond to individual rows in the table. Entities typically have relationships with other entities, and these relationships are expressed through object/relational metadata. Object/relational metadata can be specified directly in the entity class file by using annotations, or in a separate XML descriptor file distributed with the application.

The Java Persistence Query Language

{{Further2|Detailed information is available at Wikibook's Java Persistence/Querying article}}

The Java Persistence Query Language (JPQL) makes queries against entities stored in a relational database. Queries resemble SQL queries in syntax, but operate against entity objects rather than directly with database tables.

Motivation

Prior to the introduction of EJB 3.0 specification, many enterprise Java developers used lightweight persistent objects, provided by either persistence frameworks (for example Hibernate) or data access objects instead of entity beans. This is because entity beans, in previous EJB specifications, called for too much complicated code and heavy resource footprint, and they could be used only in Java EE application servers because of interconnections and dependencies in the source code between beans and DAO objects or persistence framework. Thus, many of the features originally presented in third-party persistence frameworks were incorporated into the Java Persistence API, and, as of 2006, projects like Hibernate (version 3.2) and TopLink Essentials have become themselves implementations of the Java Persistence API specification.

Related technologies

Enterprise JavaBeans

The EJB 3.0 specification (itself part of the Java EE 5 platform) included a definition of the Java Persistence API. However, end-users do not need an EJB container or a Java EE application server in order to run applications that use this persistence API.[3] Future versions of the Java Persistence API will be defined in a separate JSR and specification rather than in the EJB JSR/specification.

The Java Persistence API replaces the persistence solution of EJB 2.0 CMP (Container Managed Persistence).

Java Data Objects API

{{main article|Java Data Objects}}

The Java Persistence API was developed in part to unify the Java Data Objects API, and the EJB 2.0 Container Managed Persistence (CMP) API. {{As of|2009}} most products supporting each of those APIs support the Java Persistence API.

The Java Persistence API specifies persistence only for relational database management systems. That is, JPA focuses on object-relational mapping (ORM) (note that there are JPA providers who support other database models besides relational database, but this is outside the scope of what JPA was designed for). Refer to JPA 2 spec section 1 introduction for clarification of the role of JPA, which states very clearly "The technical objective of this work is to provide an object/relational mapping facility for the Java application developer using a Java domain model to manage a relational database."

The Java Data Objects specification supports ORM, as well as persistence to other types of database models, for example flat file databases and NoSQL databases, including document databases, graph databases, as well as literally any other conceivable datastore.

Service Data Object API

{{main article|Service Data Objects}}

The designers[4] of the Java Persistence API aimed to provide for relational persistence, with many of the key areas taken from object-relational mapping tools such as Hibernate and TopLink. Java Persistence API improved on and replaced EJB 2.0, evidenced by its inclusion in EJB 3.0. The Service Data Objects (SDO) API (JSR 235) has a very different objective to the Java Persistence API and is considered [5][6] complementary. The SDO API is designed for service-oriented architectures, multiple data formats rather than only relational data, and multiple programming languages. The Java Community Process manages the Java version of the SDO API; the C++ version of the SDO API is managed via OASIS.

Hibernate

{{main article|Hibernate (framework)}}

Hibernate provides an open source object-relational mapping framework for Java. Versions 3.2 and later provide an implementation for the Java Persistence API.[7]

Gavin King founded the Hibernate project.[8] He represented JBoss on JSR 220,[9] the JCP expert group charged with developing JPA. This led to ongoing controversy and speculation surrounding the relationship between JPA and Hibernate. Sun Microsystems has stated[10]

that ideas came from several frameworks, including Hibernate and Java Data Objects

Spring Data JPA[11]

An implementation of the repository abstraction that's a key building block of Domain-Driven Design based on the Java application framework Spring. Transparently supports all available JPA implementations and supports CRUD operations as well as the convenient execution of database queries.

JPA 2.0

Development of a new version of JPA 2.0 was started in July 2007 in the Java Community Process as JSR 317. JPA 2.0 was approved as final on 10 December 2009.

The focus of JPA 2.0 was to address features that were present in some of the popular ORM vendors, but could not gain consensus approval for JPA 1.0.

Main features included were:

  • Expanded object-relational mapping functionality
    • support for collections of embedded objects, linked in the ORM with a many-to-one relationship
    • ordered lists
    • combinations of access types
  • A criteria query API
  • standardization of SQL Hints
  • standardization of additional metadata to support DDL generation
  • support for validation
  • Shared object cache support.

Vendors supporting JPA 2.0:

  • Batoo JPA
  • DataNucleus (formerly JPOX)
  • EclipseLink (formerly Oracle TopLink)
  • IBM, for WebSphere Application Server[12]
  • JBoss with Hibernate
  • [https://github.com/impetus-opensource/Kundera Kundera]
  • ObjectDB
  • OpenJPA
  • OrientDB from Orient Technologies
  • Versant Corporation JPA (not relational, object database)[13]

JPA 2.1

Development of a new version of JPA 2.1 was started in July 2011 as JSR 338. JPA 2.1 was approved as final on 22 May 2013.

Main features included were:

  • Converters - allowing custom code conversions between database and object types.
  • Criteria Update/Delete - allows bulk updates and deletes through the Criteria API.
  • Entity Graphs - allow partial or specified fetching or merging of objects.
  • JPQL/Criteria enhancements - arithmetic sub-queries, generic database functions, join ON clause, TREAT option.
  • Schema Generation
  • Stored Procedures - allows queries to be defined for database stored procedures.

Vendors supporting JPA 2.1

  • DataNucleus
  • EclipseLink
  • Hibernate

JPA 2.2

Development of a maintenance release as JPA 2.2 was started in 2017 under JSR 338. The maintenance review was approved on 19 Jun, 2017.

Main features included were:

  • Add @Repeatable to all relevant annotations
  • Allow all JPA annotations to be used in meta-annotations.
  • Add ability to stream a query result
  • Allow AttributeConverters to be CDI injectable
  • Support Java 8 Date and Time types

Vendors supporting JPA 2.2

  • DataNucleus (from version 5.1)
  • EclipseLink (from version 2.7)
  • Hibernate (from version 5.3)
  • OpenJPA (from version 3.0)

JPA Future Work

Future JPA specification information is available here:

  • [https://java.net/projects/jpa-spec/lists JPA Specification Mailing Lists]
  • [https://java.net/jira/browse/JPA_SPEC JPA Specification JIRA]

In November 2015, Linda DeMichiel announced on the javaee-spec users mailing that Lukas Jungmann took over as the specification lead. Linda's announcement also stated, "[w]e plan to do an MR for JPA 2.2 in the Java EE 8 time frame".[14][15][16]

Tools

  • NetBeans Jeddict
  • Eclipse JPA (Dali)

See also

  • .NET Persistence API (NPA)
  • JDBC
  • MyBatis
  • OpenXava
  • pureQuery
  • SAP NetWeaver Application Server
  • XQJ

References

1. ^{{cite web| title=JavaEE 6 tutorial | url=http://docs.oracle.com/javaee/6/tutorial/doc/bnacj.html#bnadb | publisher=Oracle}}
2. ^{{cite web| title=JavaEE 7 tutorial | url=https://docs.oracle.com/javaee/7/tutorial/overview007.htm | publisher=Oracle}}
3. ^Hibernate EntityManager: Java SE environments
Hibernate EntityManager: Obtaining an EntityManager in a Java SE environment
4. ^{{cite web|title=JSR 220 Members|url=http://jcp.org/en/jsr/detail?id=220}}
5. ^{{cite web|last=Barreto |first=Charlton |title=SDO and JPA |url=http://charltonb.typepad.com/weblog/2007/10/sdo-and-jpa.html |work=Digital Walkabout |accessdate=5 May 2011 |deadurl=yes |archiveurl=https://web.archive.org/web/20110813112451/http://charltonb.typepad.com/weblog/2007/10/sdo-and-jpa.html |archivedate=13 August 2011 |df= }}
6. ^{{cite web|last=Edwards|first=Mike|title=SDO and Java Persistence Architecture (JPA)|url=http://www.osoa.org/display/Main/SDO+and+Java+Persistence+Architecture+%28JPA%29|work=Open SOA|publisher=osoa.org|accessdate=5 May 2011}}
7. ^{{cite web| title=hibernate.org - Java Persistence with Hibernate| url=http://www.hibernate.org/397.html| publisher=JBoss | accessdate=2008-11-17 | quote=Hibernate implements the Java Persistence object/relational javaAPI and persistence management interfaces }}
8. ^{{cite book| title= Java Persistence with Hibernate | url= https://books.google.com/books?id=EWVnnAEACAAJ | publisher= Manning Publications | accessdate= 8 December 2013 | quote=Gavin King is the founder of the Hibernate project |isbn= 9781617290459 }}
9. ^{{cite web| title=JBoss.com - Industry Leadership | url=http://www.jboss.com/company/leadership | publisher=JBoss | accessdate=2008-11-17 | quote=JSR 220, EJB 3.0 Spec Committee, Gavin King, Bill Burke, Marc Fleury}}
10. ^{{cite web| title=Java Persistence API FAQ | url =http://java.sun.com/javaee/overview/faq/persistence.jsp | publisher=Sun Microsystems | accessdate=2010-07-01 | quote=The Java Persistence API draws upon the best ideas from persistence technologies such as Hibernate, TopLink, and JDO |archiveurl = https://web.archive.org/web/20080822023926/http://java.sun.com/javaee/overview/faq/persistence.jsp |archivedate = 2008-08-22}}
11. ^{{cite web| title=Spring Data - Project website | url=https://projects.spring.io/spring-data| publisher=Pivotal | accessdate=2018-02-26 }}
12. ^{{Cite web|title= IBM WebSphere Application Server V7 Feature Pack for OSGi Applications and Java Persistence API |publisher= IBM |work= Download web site |date= 27 April 2010 |url= http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?subtype=ca&infotype=an&appname=iSource&supplier=897&letternum=ENUS210-129 |accessdate= 8 December 2013 }}
13. ^{{Cite web|title= Versant JPA 2-Step Download |work= Download web site |publisher= Actian |url= http://community.versant.com/jpa.aspx |accessdate= 8 December 2013 }}
14. ^{{Cite web|url=https://java.net/projects/javaee-spec/lists/users/archive/2015-11/message/1|title=Java EE Platform Specification: users@javaee-spec.java.net: Archive — Project Kenai|website=java.net|access-date=2016-11-08}}
15. ^{{Citation|last=Java|title=JavaOne LIVE - Tuesday, Mission|date=2015-10-27|url=https://www.youtube.com/watch?v=1OKEpg5zpsU#t=4h19m26s|accessdate=2016-11-08}}
16. ^{{Cite news|url=https://events.rainfocus.com/oow15/catalog/oracle.jsp?event=javaone&search=jungmann&search.event=javaoneEvent|title=What’s New in the Java Persistence API (JSR 338) [CON7631]|last=Jungmann|first=Lukas|date=10 October 2015|work=JavaOne 2015 Session Catalog|newspaper=|access-date=2016-11-08|via=rainfocus.com}}
17. ^,

External links

{{Wikibooks|Java Persistence}}

General info

  • Documentation for the final version of the EJB3 spec (called JSR220)
  • GlassFish's Persistence page
  • JCP Persistence page

Tutorials

  • Java EE 6 Persistence API Javadoc
  • Java EE 6 Persistence API tutorial
  • Java EE 7 Persistence API Javadoc
  • Java EE 7 Persistence API tutorial
  • JPA Tutorial by Prasad Kharkar
  • JPA Tutorial from Java Code Geeks
  • JPA Tutorial using OpenJPA as implementation
  • Persistence in the Java EE 5 tutorial
{{Java Persistence API}}{{Java EE 7}}{{Authority control}}{{DEFAULTSORT:Java Persistence Api}}

5 : Java APIs|Java enterprise platform|Java specification requests|Object-relational mapping|Persistence

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/24 11:30:44