JPA architecture

The Java™ Persistence API represents a simplification of the persistence programming model.

Data persistence, the ability to maintain data between application sessions in some form of nonvolatile storage (such as a relational database), is crucial to enterprise applications. Applications that are developed for this environment must either manage data persistence themselves or make use of third-party solutions to handle database updates and retrievals. JPA provides a mechanism for managing data persistence and object-relational mapping and functions for the EJB 3.0 specifications.

JPA is based on the Java programming model that applies to Java EE environments, but JPA can also function within the Java SE environment. The JPA specification defines the object-relational mapping internally, rather than relying on vendor-specific mapping implementations, and uses either annotations or XML to map objects into database tables.

JPA is designed to operate both inside and outside of a Java Enterprise Edition (Java EE) container. When you run JPA inside a container, applications can use the container to manage the persistence. If there is no container to manage JPA, the application must handle the persistence management itself. Applications designed for container managed persistence cannot be used outside a container, while applications that manage their own persistence can function either in a container environment or a Java SE environment.

JPA also provides a query language - JPQL - that you can use to retrieve objects without writing SQL queries specific to the database you are working with.

Java EE containers that support JPA must supply a persistence provider. A JPA persistence provider uses the following elements to persist data in an EJB 3.0 environment:

Feedback