In this section we are going to introduce you about the Java Persistence API. The Java Persistence API is Java standard for persisting the Java Objects (Entity) to the relational database. It provides a way to bridge the gap between Java model and relational databases.
In very simple terms you can persist or simply save your Java objects to the relational database without writing the SQL statements. The JPA provides API's is used in your program for this purpose. Java Persistence API depends on the persistence provider (ORM tool) such as Hibernate, iBatis, OpenEJB, JPA Eclipselink etc.. for actually performing the work of persistence.
The Java Persistence API was originally developed as part of JSR 220. The version of JPA is 2.1 which is a part of JEE 7 specification. JPA 2.1 provides many new features such as Stored Procedure support, Batch Updates etc.. which makes it very useful in developing demanding enterprise applications.
JPA can be used outside the EJB container which means you can use the JPA in your Java SE based applications. JPA don't need any JEE container to work. It can work outside the JEE Container. You can use the JPA based applications on the Tomcat 7 Server also.
JPA is database and JPA implementation independent. Your will be able to switch your persistence provider and also the database server. It is advisable not to use the database specific query while creating your applications.
The Java EE 7 platform needs JPA 2.1 for persistence. The Java Persistence API consists of:
The first version of JPA 1.0 was released on 11 May 2006 as a part of effort made by team of JSR 220. Then JPA 2.0 specification was released on 10th December 2009. The current version of JPA 2.1 specification is part of JEE 7 platform and was released on 22-April-2013. The JPA 2.1 was released with many new features and enables the developers to develop enterprise applications quickly.
The Entities are simple POJO Java classes which maps to the table of relational database. It is used in Java program and with the help of JPA API 's persisted in the database. The object/relational metadata is used to provide the O/R mapping instruction to the JPA environment. The object/relational metadata can be provided with the help of annotations and xml.
The JPQL or Java Persistence Query Language
The Java Persistence Query Language or simple JPQL is object-relational query language which is defined as a part of JPA Specification. The JPQL is a platform-independent O/R query language. Here name and fields of the entity object is used which internally translated into SQL by the JPA implementation at run time. It saves a lot of development time while creating the persistence layer of a enterprise application. The JPQL is used to SELECT, UPDATE and DELETE operations.
The Java Persistence API provides the API for persisting the data into relational database. Since JPA is specification it does not provides any implementation for persisting the objects, application environment must provide third-party persistence provide such as Hibernate. So, you will be able to use free or commercial persistence provider as per your business needs.
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: November 28, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles