Chapter 7 Generating JDO Persistent Objects


JDO

Java Data Objects (JDO) is a standard transparent persistence management API for Java programs that is developed as a Java Specification Request by the Java Community Process. Application programmers can use JDO to directly store their Java domain model object instances into persistent stores such as a relational database, object database or files.

JDO provides transparent persistence management. It means that a Java developer does not need to write any code for managing the persistence of business objects.

Steps To define persistent objects for JDO :

  1. Create Java classes as usual. You can use interfaces, inheritances and associations.
  2. Define O/R mapping.
  3. Define a JDO persistence descriptor.
  4. Compile the Java classes.
  5. Run the JDO enhancer to transform the Java classes into persistent objects.

Steps To use JDO persistent objects:

  1. Obtain a persistence manager.
  2. Connect to a database.
  3. Begin a transaction.
  4. Work with the Java classes as usual (use JDOQL to find objects, create new objects, modify objects, delete objects, etc.).
  5. Commit the transaction.

JDO 1.0 does not specify a standard way of defining O/R mapping. Each JDO implementation uses a different O/R mapping format. Most of the products offer limited O/R mapping possibilities.

JDO supports inheritance and navigation between objects.

JDO and Entity Bean are complementary. If you plan to use persistent objects locally without an application server or if you always access data through Session Beans, it is better to use JDO. If you need to use remote persistent objects or need better security support, you should use Entity Beans.

There are several commercial and open source implementations of JDO. For up to date information, see the websites http://www.jdocentral.com and http://java.sun.com/products/jdo/ .

 


Copyright (C) 2008. Sybase Inc. All rights reserved.