Tuesday, September 30, 2008

What is JPA.....?

The Java Persistence Architecture API (JPA) is a Java specification for accessing, persisting and managing data between Java objects / classes and the relational database. JPA was defined as part of the EJB 3.0 specification as a replacement to the EJB 2 CMP Entity Beans specification. It is now considered the standard industry approach for Object to Relational Mapping (ORM) in the Java Industry.

JPA is just a specification, it is not a product, and cannot perform persistence, or anything by itself. JPA is just a set of interfaces, and requires an implementation. There are open source and commercial JPA implementations to choose from and any Java EE 5 application server should provide support for its' use. JPA also requires a database to persist to.

JPA allows POJO (Plain Old Java Objects) to be easily persisted without requiring the classes to implement any interfaces or methods as the EJB 2 CMP specification required. JPA allows the object's object-relational mappings to be defined through standard annotations or XML defining how the Java class maps to a relational database table. JPA also defined a runtime EntityManager API for processing queries and transaction on the objects against the database. JPA defines a object-level query language JPQL to allow querying of the objects from the database.

JPA is the latest of several Java persistence specifications. The first being the OMG persistence service Java binding, which was never very successful and I'm not sure of any commercial products supporting it. Next came EJB 1.0 CMP Entity Beans, which was very successful in being adopted by the big Java EE providers (BEA, IBM), but there was a backlash against the spec by some users who thought the spec requirements on the Entity Beans overly complex and overhead and performance poor. EJB 2.0 CMP tried to reduce some of the complexity of Entity Beans through introducing local interfaces, but the majority of the complexity remained. EJB 2.0 also lacked portability, in that the deployment descriptors defining the object-relational mapping were not specified and all proprietary.

Search This Blog