JPA Architecture: In this section we will discuss the architecture of JPA specification. Java Persistence API or JPA for short is a lightweight, POJO-based Java framework to persist the Java Objects to the relational database. JPA is uses metadata to map the persistence objects with the database table. JPA supports SQL like query language to ease the process of querying the database. JPA Query language can be used to execute both static and dynamic queries.
JPA supports many ORM frameworks available these days. You can use either free or commercial ORM framework in your JPA based applications. It's also very easy to switch to different ORM frameworks.
List of ORM frameworks:
You can easily plug any persistence provider into your JPA application.
JPA concept includes the three components Entity, EntityManager and EntityManagerFactory. Following diagram shows the primary components of JPA architecture.
Entity is the persistence (POJO) objects that represent one record in the table. The Entity is simple annoted POJO class, which is easy to develop. Here are the characteristics of an Entity:
The EntityManager interface is providing the API for interacting with the Entity. Some of the functions provided by EntityManager API are:
You will learn about all these functions in next sections. We have developed many JPA examples to help you in learning JPA.
EntityManagerFactoryThe EntityManagerFactory is used to create an instance of EntityManager. In your application when there is no use of EntityManagerFactory or application shuts down then it is necessary to close the instance of EntityManagerFactory . Once the EntityManagerFactory is closed, all its EntityManagers are also closed.
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: December 12, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles