JDO Predefined ID Classes
An object ID is a combination of a persistence capable class and a primary key. It provides a unique representation of a persistent object.
The following classes serve as predefined ID classes for persistence capable classes with a simple single field primary key:
- javax.jdo.identity.ByteIdentity - JDO Class
- javax.jdo.identity.CharIdentity - JDO Class
- javax.jdo.identity.IntIdentity - JDO Class
- javax.jdo.identity.LongIdentity - JDO Class
- javax.jdo.identity.ObjectIdentity - JDO Class
- javax.jdo.identity.ShortIdentity - JDO Class
- javax.jdo.identity.StringIdentity - JDO Class
- javax.jdo.identity.SingleFieldIdentity - JDO Class
Object IDs are used in many PersistenceManager
methods (getObjectId
, getObjectById
, getObjectByIds
, etc.) to represent objects but should not be used as the type of a primary key field in a persistence capable class.
For example, to use a String
primary key define a primary key field of type String
:
@PersistenceCapable public class MyClass { @PrimaryKey String id; }
Persistent objects with a String primary key (including instances of MyClass
) can be represented uniquely by StringIdentity
, as a combination of a class and a string value.