toring and retrieving information for most applications usually involves some form of interaction with a relational database. This has presented a fundamental problem for developers for quite some time since the design of relational data and object-oriented instances share very different relationship structures within their respective environments. Relational databases are structured in a tabular configuration and object-oriented instances are typically structured in a hierarchical manner. This "impedance mismatch" has led to the development of several different object-persistence technologies attempting to bridge the gap between the relational world and the object-oriented world. The Java Data Objects (JDO) API provides yet another means for bridging this gap.
This article is the second in a series discussing how three different object-persistence technologies (EJB, Java Data Objects, and Hibernate) attempt to simplify the chore of connecting relational databases and the Java programming language.
Introducing Object Persistence
Persisting Java objects to a relational database is a unique challenge that involves serializing hierarchically-structured Java objects to a tabular-structured database and vice versa. This challenge is currently being addressed by a number of different tools. Most of these tools allow developers to instruct persistence engines as to how to convert Java objects to database columns/records and back. Essential to this effort is the need to map Java objects to database columns and records in a manner optimized for speed and efficiency.
The Java Data Objects (JDO) API provides a standard, straightforward way of achieving object persistence in Java technology. JDO uses a practical combination of XML metadata and bytecode enhancement to ease development complexity and overhead, as compared to other object binding technologies.
An Overview of JDO
The JDO API, consisting of just a few interfaces, is one of the simplest APIs to learn of all the standardized persistence technologies currently available. There are many implementations of the JDO API from which to choose. The JDO reference implementation is freely available from Sun.
One reason for JDO's simplicity is that it allows you to work with plain old Java objects (POJOs) instead of proprietary APIs. JDO addresses most of the persistence augmentation in a post-compilation bytecode enhancement step, thus providing an abstraction layer between the application code and the persistence engine.
JDO has fallen under attack for a number of reasons, including: The code-enhancer model should be replaced by a transparent persistence model; vendors could lose their proprietary lock-in; JDO overlaps too much with EJBs and CMP. Despite these points of resistance, many experts are touting JDO as a vast improvement over the current trends in object-to-data and data-to-object technologies.