| Free tutorials for Java, Eclipse and Web programming |
Version 0.9
Copyright © 2008 - 2009 Lars Vogel
13.10.2009
| Revision History | ||
|---|---|---|
| Revision 0.1 | 03.02.2008 | Lars Vogel |
| OpenJPA | ||
| Revision 0.2 | 29.09.2008 | Lars Vogel |
| Added EclipseLink | ||
| Revision 0.3 | 16.10.2008 | Lars Vogel |
| Bug fixes | ||
| Revision 0.4 | 08.01.2009 | Lars Vogel |
| Reworked and cleaned up the article | ||
| Revision 0.5 | 21.01.2009 | Lars Vogel |
| Moved OpenJPA to another articles | ||
| Revision 0.6 | 22.01.2009 | Lars Vogel |
| Used JUnit for the example | ||
| Revision 0.7 | 03.02.2009 | Lars Vogel |
| Changed ID generation strategy to Table | ||
| Revision 0.8 | 30.05.2009 | Lars Vogel |
| Minor re-work | ||
| Revision 0.9 | 14.10.2009 | Lars Vogel |
| Improved JPA overview chapter, described persistence.xml parameters | ||
Table of Contents
The Java Persistence API (JPA) is a specification for persisting Java objects into a relational database. The Java Persistence API let the developer easily map, store, update and retrieve data from relational database tables into Java Objects and vice versa.
The Java Persistence API simplifies the life of a developer to a great degree. It permits the developer to work with objects rather then with SQL statements.
JPA can be used in Java-EE and Java-SE applications.
This process of mapping POJO's (Plain old Java Objects) to database tables and vice versa is called Object-relational mapping (ORM). This mapping is defined via persistence metadata, which defines the mapping to the database and the relationship between the objects.
This metadata can be specified using Java annotations or XML mapping files or a combination of both. If available the XML configuration overwrites the annotations in the Java code.
JPA also defines a powerful SQL-like Query language for static and dynamic queries.
JPA is a specification and for using JPA you always need a JPA provider.
The JPA provider will use the persistence metadata information to perform the correct database operations.
Most JPA persistence provider offer the option to create automatically the database schema based on the metadata.
The persistence provider is the JPA implementation. The usage of JPA requires that an JPA provider implementation is added to the classpath.
<provider>org.eclipse.persistence.jpa.PersistenceProvider </provider>