Chapter 2. Why JPA?

Java developers who need to store and retrieve persistent data already have several options available to them: serialization, JDBC, JDO, proprietary object-relational mapping tools, object databases, and EJB 2 entity beans. Why introduce yet another persistence framework? The answer to this question is that with the exception of JDO, each of the aforementioned persistence solutions has severe limitations. JPA attempts to overcome these limitations, as illustrated by the table below.

Table 2.1. Persistence Mechanisms

Supports:SerializationJDBCORMODBEJB 2JDOJPA
Java Objects Yes No Yes Yes Yes Yes Yes
Advanced OO Concepts Yes No Yes Yes No Yes Yes
Transactional IntegrityNo Yes Yes Yes Yes Yes Yes
ConcurrencyNo Yes Yes Yes Yes Yes Yes
Large Data SetsNo Yes Yes Yes Yes Yes Yes
Existing SchemaNo Yes Yes No Yes Yes Yes
Relational and Non-Relational Stores NoNoNoNo Yes Yes No
QueriesNo Yes Yes Yes Yes Yes Yes
Strict Standards / Portability Yes NoNoNo Yes Yes Yes
Simplicity Yes Yes Yes Yes No Yes Yes

JPA combines the best features from each of the persistence mechanisms listed above. Creating entities under JPA is as simple as creating serializable classes. JPA supports the large data sets, data consistency, concurrent use, and query capabilities of JDBC. Like object-relational software and object databases, JPA allows the use of advanced object-oriented concepts such as inheritance. JPA avoids vendor lock-in by relying on a strict specification like JDO and EJB 2.x entities. JPA focuses on relational databases. And like JDO, JPA is extremely easy to use.


Kodo typically stores data in relational databases, but can be customized for use with non-relational datastores as well.

JPA is not ideal for every application. For many applications, though, it provides an exciting alternative to other persistence mechanisms.


Skip navigation bar   Back to Top