ObjectDB ObjectDB

getObjectId(pc) - JDO PersistenceManager's method

Method
javax.jdo.PersistenceManager
Object getObjectId(
  Object pc
)

The ObjectId returned by this method represents the JDO identity of the instance. The ObjectId is a copy (clone) of the internal state of the instance, and changing it does not affect the JDO identity of the instance.

The getObjectId method returns an ObjectId instance that represents the object identity of the specified JDO instance. The identity is guaranteed to be unique only in the context of the JDO PersistenceManager that created the identity, and only for two types of JDO Identity: those that are managed by the application, and those that are managed by the data store.

If the object identity is being changed in the transaction, by the application modifying one or more of the application key fields, then this method returns the identity as of the beginning of the transaction. The value returned by getObjectId will be different following afterCompletion processing for successful transactions.

Within a transaction, the ObjectId returned will compare equal to the ObjectId returned by only one among all JDO instances associated with the PersistenceManager regardless of the type of ObjectId.

The ObjectId does not necessarily contain any internal state of the instance, nor is it necessarily an instance of the class used to manage identity internally. Therefore, if the application makes a change to the ObjectId instance returned by this method, there is no effect on the instance from which the ObjectId was obtained.

The getObjectById method can be used between instances of PersistenceManager of different JDO vendors only for instances of persistence capable classes using application-managed (primary key) JDO identity. If it is used for instances of classes using datastore identity, the method might succeed, but there are no guarantees that the parameter and return instances are related in any way.

Parameters:
pc - the PersistenceCapable instance
Returns:
the ObjectId of the instance
Since:
JDO 1.0
See Also:
getTransactionalObjectId(Object pc)
getObjectById(Object oid, boolean validate)