JDO Identity

This section contains documentation, tutorials and use-cases of JDO Object Identity mappings.

JDO Identity can be accomplished in several ways:

  1. Application (primary key) Identity
    1. Single Field Identity
  2. Datastore Identity
  3. Nondurable JDO Identity

Application (primary key) Identity

The following is drawn from section 5.4.1 of the JSR 243 Specification

JDO identity is managed by the application. The class provided by the application that implements the JDO object id has all of the characteristics of an RMI remote object, making it possible to use the JDO object id class as the EJB primary key class. Specifically:
  • the ObjectId class must be public;
  • the ObjectId class must implement Serializable;
  • the ObjectId class must have a public no-arg constructor, which might be the default constructor;
  • the field types of all non-static fields in the ObjectId class must be serializable, and for portability should be primitive, String, Date, Byte, Short, Integer, Long, Float, Double, BigDecimal, or BigInteger types; JDO implementations are required to support these types and might support other reference types;
  • all serializable non-static fields in the ObjectId class must be public;
  • the names of the non-static fields in the ObjectId class must include the names of the primary key fields in the JDO class, and the types of the corresponding fields must be identical;
  • the equals() and hashCode() methods of the ObjectId class must use the value(s) of all the fields corresponding to the primary key fields in the JDO class;
  • if the ObjectId class is an inner class, it must be static;
  • the ObjectId class must override the toString() method defined in Object, and return a String that can be used as the parameter of a constructor;
  • the ObjectId class must provide a constructor taking either a String alone or a Class and String that returns an instance that compares equal to an instance that returned that String by the toString() method.

In the CORM Project, there is an example object and unit test for creating an application-managed primary key.

Navigation

JDO

Usage Examples

Sponsored Links

r3 - 31 Jan 2006 - 22:17 - AlexanderSaintCroix
Copyright © 2005-2006 Alexander Saint Croix. All material on this collaboration platform is the property of the contributing authors.
Powered by TWiki/Dakar Wed, 14 Dec 2005 build 7851