ArticleslgStudy

science

Jakarta Persistence

Jakarta Persistence is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Jakarta Persistence rather than just read about it. In short: Jakarta Persistence, also known as JPA (abbreviated from the former name Java Persistence API) is a Jakarta EE application programming interface specification that describes the management of relational data in enterprise Java applications. Persistence in this context covers three areas: The API itself, defined in the jakarta.persistence package (javax.persistence for Jakarta EE 8 and below) The Jakarta Persistence…

Key takeaways

  • Jakarta Persistence belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Jakarta Persistence to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Jakarta Persistence from memory before moving on to harder problems.

Reference excerpt

Jakarta Persistence, also known as JPA (abbreviated from the former name Java Persistence API) is a Jakarta EE application programming interface specification that describes the management of relational data in enterprise Java applications. Persistence in this context covers three areas:

The API itself, defined in the jakarta.persistence package (javax.persistence for Jakarta EE 8 and below) The Jakarta Persistence Query Language (JPQL; formerly Java Persistence Query Language) Object/relational metadata

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). The JPA 2.1 specification was released 22 April 2013 (the Java EE 7 platform requires JPA 2.1). The JPA 2.2 specification was released in the summer of 2017. The reference implementation for JPA 1 and 2 was EclipseLink. Jakarta Persistence 3.1 was released in the spring of 2022 as part of Jakarta EE 10. Jakarta Persistence 3.2 was released in spring 2024, targeting inclusion in Jakarta EE 11. EclipseLink and Hibernate are compatible implementations.

Entities 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 the entity class file by using annotations or in a separate XML descriptor file distributed with the application.

Example 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 the default table name in the @Table annotation), or to create associations between entities.

Query Language

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.

Motivation 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 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 the Java Persistence API, and projects such as Hibernate and TopLink Essentials have become implementations of the Java Persistence API specification.

Related technologies

Enterprise Beans 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 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

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 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 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.

Hibernate

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 the relationship between JPA and Hibernate. Sun Microsystems stated that ideas came from several frameworks, including Hibernate and Java Data Objects.

Spring Data JPA 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 the convenient execution of database queries.

Version history

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:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Jakarta Persistence

Start with the simplest possible case. Write down what Jakarta Persistence claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Jakarta Persistence before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Jakarta Persistence ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Jakarta Persistence

In research
Jakarta Persistence appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Jakarta Persistence in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Jakarta Persistence is common in secondary-school and first-year university syllabi. It links to neighbouring topics Java APIs, Java enterprise platform, Java specification requests, so understanding it makes those chapters shorter.
In everyday life
Look for Jakarta Persistence outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Jakarta Persistence” →

How to study Jakarta Persistence in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Jakarta Persistence means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Jakarta Persistence out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Jakarta Persistence in simple terms?

Jakarta Persistence, also known as JPA (abbreviated from the former name Java Persistence API) is a Jakarta EE application programming interface specification that describes the management of relational data in enterprise Java applications. Persistence in this context covers three areas: The API it…

Why does Jakarta Persistence matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Jakarta Persistence?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Jakarta Persistence.

Tags

  • Java APIs
  • Java enterprise platform
  • Java specification requests
  • Object–relational mapping
  • Persistence

Keep exploring