Chapter 2. Why EJB Persistence?

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. EJB persistence attempts to overcome these limitations, as illustrated by the table below.

Table 2.1. Persistence Mechanisms

Supports:SerializationJDBCORMODBEJB 2JDOEJB 3
Java ObjectsYesNoYesYesYesYesYes
Advanced OO ConceptsYesNoYesYesNoYesYes
Transactional IntegrityNoYesYesYesYesYesYes
ConcurrencyNoYesYesYesYesYesYes
Large Data SetsNoYesYesYesYesYesYes
Existing SchemaNoYesYesNoYesYesYes
Relational and Non-Relational Stores NoNoNoNoYesYesNo
QueriesNoYesYesYesYesYesYes
Strict Standards / PortabilityYesNoNoNoYesYesYes
SimplicityYesYesYesYesNoYesYes

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

[Note]Note

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

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