Home » JDO » PersistenceCapable » jdoCopyKeyFieldsToObjectId(fm, oid) - JDO PersistenceCapable's method

jdoCopyKeyFieldsToObjectId(fm, oid) - JDO PersistenceCapable's method

Method
javax.jdo.spi.PersistenceCapable
void jdoCopyKeyFieldsToObjectId(
  ObjectIdFieldSupplier fm,
  Object oid
)

Copy fields from an outside source to the key fields in the ObjectId. This method is generated in the PersistenceCapable class to generate a call to the field manager for each key field in the ObjectId. For example, an ObjectId class that has three key fields (int id, String name, and Float salary) would have the method generated:

void jdoCopyKeyFieldsToObjectId

(ObjectIdFieldSupplier fm, Object objectId) {

EmployeeKey oid = (EmployeeKey)objectId;

oid.id = fm.fetchIntField (0);

oid.name = fm.fetchStringField (1);

oid.salary = fm.fetchObjectField (2);

}

The implementation is responsible for implementing the ObjectIdFieldSupplier to produce the values for the key fields.

For classes using single field identity, this method always throws JDOUserException.

Parameters:
fm - the field supplier that supplies the field values.
oid - the ObjectId target of the copy.
Since:
JDO 1.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.