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

Method
javax.jdo.spi.JDOImplHelper
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
Parameters:
pcClass - the PersistenceCapable class.
obj - the Object form of the object id
Returns:
the new ObjectId instance, or null if the class is not registered.
Since:
JDO 2.0

This documentation page is derived (with some adjustments) from the JDO 2.2 API
and is available under the terms of the Apache License, v. 2.0.