ObjectDB ObjectDB

newObjectIdInstance(pcClass, obj) - JDO JDOImplHelper's method

Object newObjectIdInstance(
  Class pcClass,
  Object obj

Create a new instance of the class used by the parameter Class for JDO identity, using the key constructor of the object id class. It is intended for single field identity. The identity instance returned has no relationship with the values of the primary key fields of the persistence-capable instance on which the method is called. If the key is the wrong class for the object id class, null is returned.

For classes that use single field identity, if the parameter is of one of the following types, the behavior must be as specified:

  • Number or Character: the parameter must be the single field type or the wrapper class of the primitive field type; the parameter is passed to the single field identity constructor
  • ObjectIdFieldSupplier: the field value is fetched from the ObjectIdFieldSupplier and passed to the single field identity constructor
  • String: the String is passed to the single field identity constructor
pcClass - the PersistenceCapable class.
obj - the Object form of the object id
the new ObjectId instance, or null if the class is not registered.
JDO 2.0