Introduction to the Java Persistence API

In this section, we are going to discuss about the Java Persistence API (JPA).
It is a part of Java EE5 (Java Enterprise Edition 5) and EJB 3.0 (Enterprise
Java Beans 3.0) specification.
Java Persistence API provides simple POJO (Plain Old Java Object) class and
standard OR mapping (Object Relational mapping).
[POJO : It stands for Plain Old Java Object that
is used for referring the Java objects. This is a very simple class that
contains all normal java objects. It doesn't extend or implement specialized
classes.]
To use JPA you must be configured the JPA behavior of
your entities using annotations. The JPA behavior is managed by the JPA
persistence The JPA provides the facility to Java developers for managing an
object relational data in Java applications called an object/relational mapping.
The most important feature of JPA is that it is an independent API and easily
integrate with J2EE as well as J2SE applications.
The JPA also provides the facility to load and save the
data into database table without using any SQL query. As like if you use the the
persist() method then it executes the insert SQL and merge()
method updates your records by update query.
The javax.persistence: This is the package
that contains all classes, interfaces and annotations that makes up the JPA.
Java Persistence can be used the following areas:
- To persist the Java object into database
- To query database
- To update the Java object into database
There are following JPA programming models:
- EntityManager API : It consists persist,
update, retrieve, or remove objects from a database table.
- EntityManager API and object-relational
mapping meta-data handles the database operations without writing JDBC or
SQL query.
- JPA also provides the query language, for
handling EJB querying language (known as JPQL). To retrieve objects without
using SQL queries.
|