Jakarta Persistence , also known as JPA (abbreviated from formerly name Java Persistence API ) is a Jakarta EE application programming interface specification that describes the management of relational data in enterprise Java applications.
32-547: Persistence in this context covers three areas: The reference implementation for JPA is EclipseLink . 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). The JPA 2.1 specification was released 22 April 2013 (the Java EE 7 platform requires JPA 2.1). The JPA 2.2 specification
64-473: A crash or unexpected shutdown. Operating systems that employ this ability include Java Data Objects Java Data Objects ( JDO ) is a specification of Java object persistence . One of its features is a transparency of the persistence services to the domain model . JDO persistent objects are ordinary Java programming language classes ( POJOs ); there is no requirement for them to implement certain interfaces or extend from special classes. JDO 1.0
96-435: A file. Shortcomings : Requires enough RAM to hold the entire system state. State changes made to a system after its last image was saved are lost in the case of a system failure or shutdown. Saving an image for every single change would be too time-consuming for most systems, so images are not used as the single persistence technique for critical systems. Using journals is the second simplest persistence technique. Journaling
128-471: A non-transparent way by requiring specific storage-API calls or in a transparent way with automatic program transformation . This results in code that is slower than native code and more complicated to debug. Any software layer that makes it easier for a program to persist its state is generically called a persistence layer. Most persistence layers will not achieve persistence directly but will use an underlying database management system . System prevalence
160-405: A program. The use of the transitive verb "persist" (describing an action performed by a program) is a back-formation. Orthogonal persistence is widely adopted in operating systems for hibernation and in platform virtualization systems such as VMware and VirtualBox for state saving. Research prototype languages such as PS-algol , Napier88 , Fibonacci and pJama, successfully demonstrated
192-505: Is a technique that combines system images and transaction journals, mentioned above, to overcome their limitations. Shortcomings: A prevalent system must have enough RAM to hold the entire system state. DBMSs use a combination of the dirty writes and transaction journaling techniques mentioned above. They provide not only persistence but also other services such as queries, auditing and access control. Persistent operating systems are operating systems that remain persistent even after
224-566: Is an object-relational mapping (ORM) standard, while JDO is both an object-relational mapping standard and a transparent object persistence standard. JDO, from an API point of view, is agnostic to the technology of the underlying datastore, whereas JPA is targeted to RDBMS datastores (although there are several JPA providers that support access to non-relational datastores through the JPA API, such as DataNucleus and ObjectDB). Leading JDO commercial implementations and open source projects also offer
256-420: Is because entity beans, in previous EJB specifications, called for much complicated code and imposed a heavy resource footprint, and they could be used only on Java EE application servers because of interconnections and dependencies in the source code between beans and DAO objects or persistence frameworks. Thus, many of the features originally presented in third-party persistence frameworks were incorporated into
288-448: Is integrated with Java EE in several ways. First of all, the vendor implementation may be provided as a JEE Connector . Secondly, JDO may work in the context of JEE transaction services . Enterprise JavaBeans 3.0 (EJB3) specification also covered persistence, as had EJB v2 with Entity Beans . There have been standards conflicts between the two standards bodies in terms of pre-eminence. JDO has several commercial implementations. In
320-449: Is not mandated by the JDO specification, although it is the commonly used mechanism for implementing the JDO specification's requirements.) Currently, JDO vendors offer several options for persistence, e.g. to RDBMS , to OODB , or to files . JDO enhanced classes are portable across different vendors' implementation. Once enhanced, a Java class can be used with any vendor's JDO product. JDO
352-414: Is said to be " orthogonal " or "transparent" when it is implemented as an intrinsic property of the execution environment of a program. An orthogonal persistence environment does not require any specific actions by programs running in it to retrieve or save their state . Non-orthogonal persistence requires data to be written and read to and from storage using specific instructions in a program, resulting in
SECTION 10
#1732780498200384-412: Is the process of storing events in a log before each one is applied to a system. Such logs are called journals. On startup, the journal is read and each event is reapplied to the system, avoiding data loss in the case of system failure or shutdown. The entire "Undo/Redo" history of user commands in a picture editing program, for example, when written to a file, constitutes a journal capable of recovering
416-406: Is the writing to storage of only those portions of system state that have been modified (are dirty) since their last write. Sophisticated document editing applications, for example, will use dirty writes to save only those portions of a document that were actually changed since the last save. Shortcomings: This technique requires state changes to be intercepted within a program. This is achieved in
448-444: The process that created it. This is achieved in practice by storing the state as data in computer data storage . Programs have to transfer data to and from storage devices and have to provide mappings from the native programming-language data structures to the storage device data structures. Picture editing programs or word processors , for example, achieve state persistence by saving their documents to files . Persistence
480-670: 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). 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. Most products supporting each of
512-426: The Java Persistence API, and projects such as Hibernate and TopLink Essentials have become implementations of the Java Persistence API specification. The EJB 3.0 specification (itself part of the Java EE 5 platform) included a definition of the Java Persistence API. However, developers do not need an EJB container or a Java EE application server to run applications that use this persistence API. Future versions of
544-489: 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 any many other datastores. The designers of the Java Persistence API aimed to provide for relational persistence, with many of
576-629: The Java version of the SDO API; the C++ version of the SDO API is managed via OASIS . Hibernate, founded by Gavin King, provides an open source object-relational mapping framework for Java . Versions 3.2 and later provide an implementation for the Java Persistence API. King represented JBoss on JSR 220, the JCP expert group charged with developing JPA. This led to ongoing controversy and speculation surrounding
608-437: The concepts along with the advantages to programmers. Using system images is the simplest persistence strategy. Notebook hibernation is an example of orthogonal persistence using a system image because it does not require any actions by the programs running on the machine. An example of non-orthogonal persistence using a system image is a simple text editing program executing specific instructions to save an entire document to
640-613: The convenient execution of database queries. 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: Vendors supporting JPA 2.0: Development of JPA version 2.1 began in July 2011 as JSR 338. JPA 2.1
672-632: The default table name in the @Table annotation), or to create associations between entities. The Jakarta Persistence Query Language (JPQL; formerly Java Persistence Query Language) 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. Prior to the introduction of EJB 3.0 specification, many enterprise Java developers used lightweight persistent objects provided by either persistence frameworks (such as Hibernate ) or data access objects (DAO) instead of by using entity beans . This
SECTION 20
#1732780498200704-575: The end, persistence has been "broken out" of "EJB3 Core", and a new standard formed, the Java Persistence API (JPA). JPA uses the javax.persistence package, and was first specified in a separate document within the EJB3 spec JSR 220 , but was later moved to its own spec JSR 317 . Significantly, javax.persistence will not require an EJB container, and thus will work within a Java SE environment as well, as JDO always has. JPA, however,
736-497: The entity class file by using annotations or in a separate XML descriptor file distributed with the application. An example entity class with ORM metadata declared using annotations (import statements and setters/getters are omitted for simplicity). The @Entity annotation declares that the class represents an entity. @Id declares the attribute which acts as the primary key of the entity. Additional annotations may be used to declare additional metadata (for example changing
768-523: 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 that of the Java Persistence API and is considered 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
800-435: The relationship between JPA and Hibernate. Sun Microsystems stated that ideas came from several frameworks, including Hibernate and Java Data Objects . The Spring Data JPA is an implementation of the repository abstraction that is a key building block of domain-driven design based on the Java application framework Spring . It transparently supports all available JPA implementations and supports CRUD operations as well as
832-468: The state of an edited picture at any point in time. Journals are used by journaling file systems , prevalent systems and database management systems where they are also called "transaction logs" or "redo logs". Shortcomings : When journals are used exclusively, the entire (potentially large) history of all system events must be reapplied on every system startup. As a result, journals are often combined with other persistence techniques. This technique
864-449: The two APIs support the Java Persistence API. The Java Persistence API specifies persistence only for relational database management systems by focusing on object-relational mapping (ORM). Some JPA providers support other database models , though this is outside the scope of JPA's design. The introduction section of the JPA specification states: "The technical objective of this work is to provide an object/relational mapping facility for
896-444: The use of persist as a transitive verb: On completion, the program persists the data . The advantage of orthogonal persistence environments is simpler and less error-prone programs. The term "persistent" was first introduced by Atkinson and Morrison in the sense of orthogonal persistence: they used an adjective rather than a verb to emphasize persistence as a property of the data, as distinct from an imperative action performed by
928-542: Was approved as final on 22 May 2013. Main features included were: Vendors supporting JPA 2.1: Development of JPA 2.2, a maintenance release, began in 2017 under JSR 338. The maintenance review was approved on 19 June 2017. Main features included were: Vendors supporting JPA 2.2: The JPA was renamed as Jakarta Persistence in 2019 and version 3.0 was released in 2020. This included the renaming of packages and properties from javax.persistence to jakarta.persistence. Vendors supporting Jakarta Persistence 3.0: Version 3.1
960-838: Was developed under the Java Community Process as JSR 12 . JDO 2.0 was developed under JSR 243 and was released on May 10, 2006. JDO 2.1 was completed in Feb 2008, developed by the Apache JDO project. JDO 2.2 was released in October 2008. JDO 3.0 was released in April 2010. Object persistence is defined in the external XML metafiles, which may have vendor-specific extensions. JDO vendors provide developers with enhancers , which modify compiled Java class files so they can be transparently persisted. (Note that byte-code enhancement
992-421: Was released in 2022. It is part of Jakarta EE 10, and thus requires at least Java 11 to run. It adds better UUID handling, various new JPQL functions for math and date/time handling, and other small changes. Vendors supporting Jakarta Persistence 3.1: Persistence (computer science) In computer science , persistence refers to the characteristic of state of a system that outlives (persists more than)
Jakarta Persistence - Misplaced Pages Continue
1024-538: Was released in the summer of 2017. The JPA 3.1 specification, the latest version, was released in the spring of 2022 as part of Jakarta EE 10. A persistence entity is a lightweight Java class with its state 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 mapping (ORM) metadata. This metadata may be specified directly in
#199800