Introduction to JPA in Java EE Architecture by MyExamCloud

The Java EE 6 Java Persistence API introduction tutorial by MyExamCloud

The Java EE 6 Java Persistence API introduction tutorial by MyExamCloudThe data access plays major role in any application starting from Mobile App to Enterprise Application. We have plenty of options to choose from different relational database management system (RDBMS) vendors. The RDBMS itself have so many components to manage the data within the system, but to access and manage date on our application we need connectivity interface.

The connectivity interface from Java application is called JDBC (Java Database Connectivity). Java Database Connectivity (JDBC) is an application programming interface (API) for the programming language Java, which defines how a client may access a database.

Sun Microsystems released JDBC as part of Java Development Kit (JDK) 1.1 on February 19, 1997. Since then it has been part of the Java Platform, Standard Edition (Java SE).

The history behind JPA:
The Java developers used JDBC to connect RDBMS to manage data in any application including enterprise applications before 1998.jdbc-rdbms

Later the DAO (Data Access Object) was used to simplify the data access process.dao-jdbc-rdbms

The first announcement of the JPE (Java Professional Edition, later version is renamed as J2EE) project at Sun was made on May 1998.  On December 12, 1999 J2EE 1.2 was released with much improved components and APIs for enterprise application development and they are given below:

JDBC Standard Extension API 2
Java Naming and Directory Interface Specification (JNDI)  1.2
RMI-IIOP 1.1
Java Servlet 2.2
JavaServer Pages (JSP)  1.1
Enterprise JavaBeans (EJB)  1.1
Java Message Service API (JMS)  1
Java Transaction API (JTA)  1
JavaMail API  1.1
JavaBeans Activation Framework (JAF) 1

The Enterprise JavaBeans (EJB) component comes with Entity Beans to manage RDBMS data in your enterprise application. You can read this tutorial about EJB components. http://www.epractizelabs.com/myexamcloud/2016/04/21/ejb-component-java-ee-architecture/

The Entity Beans are further divided into based on data management.
1.   Container Managed Bean (CMP) – delegate persistence management function to its EJB Container
2.   Bean Managed Bean (BMP) – manage its own persistenceEntity-Beans-management

The first version of Entity Beans does not have local views, so developer must rely on RMI-IIOP protocol to call an EJB. This is time consuming and performance overhead. So the next version comes with Local Entity Beans and they are treated as local calls within the container.

In 2001, Hibernate open source framework was released for object-relational mapping for the Java language. The Hibernate provides a framework for mapping an object-oriented domain model to a relational database.

The Hibernate framework was much popular among Java EE developers and most of them skipped using Entity Beans due to following reasons:

Lot of additional code.
No support for polymorphism or inheritance.
Additional overhead of Entity Beans hurt performance, especially if used remotely.
Additional creation of Value or Data Transfer Objects are usually recommended.
Entity Beans take a lot longer to build and deploy than normal Java classes.

The Sun Microsystem started thinking about these issues and want to develop simple Java based persistence framework and the outcome is JPA. The Java Persistence API (JPA) is a Java application programming interface specification that describes the management of relational data in applications using Java Platform, Standard Edition and Java Platform, Enterprise Edition.Java-Persistence-API

By JPA we can avoid writing DDL in a database specific dialect of SQL. Instead we can write “mappings” in XML, or using Java annotations.

By JPA we can also avoid writing DML in the database specific dialect of SQL.

By JPA we can load and save Java objects and graphs without any DML language at all.

When you do need to perform queries JPQL allows you to express the queries in terms of the Java entities rather than the (native) SQL tables and columns.

JPA is simpler, cleaner and less labour intensive than JDBC + SQL + hand-written mappings.

The same entity can be directly used as DTO (Data Transfer Object). This is not possible in the case of Entity Beans.

One of the best way to learn JPA is by taking Oracle’s JPA Certification. You can checkout the JPA Certification details athttp://www.myexamcloud.com/onlineexam/viewStudyPlan.html?s=KgjalwTpV7w= .

Leave a Reply

Your email address will not be published. Required fields are marked *