FileDocCategorySizeDatePackage
PersistenceCapable.javaAPI DocGlassfish v2 API7482Fri May 04 22:34:56 BST 2007com.sun.jdo.api.persistence.support

PersistenceCapable

public interface PersistenceCapable
A class that can be managed by a JDO implementation.

Every class whose instances can be managed by a JDO PersistenceManager must implement the PersistenceCapable interface.

This interface defines methods that allow the implementation to manage the instances. It also defines methods that allow a JDO aware application to examine the runtime state of instances. For example, an application can discover whether the instance is persistent, transactional, dirty, new, or deleted; and to get its associated PersistenceManager if it has one.

In the Reference Implementation, the JDO Enhancer modifies the class to implement PersistenceCapable prior to loading the class into the runtime environment. The Reference Enhancer also adds code to implement the methods defined by PersistenceCapable.

The PersistenceCapable interface is designed to avoid name conflicts in the scope of user-defined classes. All of its declared method names are prefixed with 'jdo'.

Fields Summary
Constructors Summary
Methods Summary
public java.lang.ObjectjdoGetObjectId()
Return a copy of the JDO identity associated with this instance.

Persistent instances of PersistenceCapable classes have a JDO identity managed by the PersistenceManager. This method returns a copy of the ObjectId that represents the JDO identity.

Transient instances return null.

The ObjectId may be serialized and later restored, and used with a PersistenceManager from the same JDO implementation to locate a persistent instance with the same data store identity.

If the JDO identity is managed by the application, then the ObjectId may be used with a PersistenceManager from any JDO implementation that supports the PersistenceCapable class.

If the JDO identity is not managed by the application or the data store, then the ObjectId returned is only valid within the current transaction.

see
PersistenceManager#getObjectId(Object pc)
see
PersistenceManager#getObjectById(Object oid)
return
a copy of the ObjectId of this instance.

public PersistenceManagerjdoGetPersistenceManager()
Return the associated PersistenceManager if there is one. Transactional and persistent instances return the associated PersistenceManager.

Transient non-transactional instances return null.

return
the PersistenceManager associated with this instance.

public booleanjdoIsDeleted()
Tests whether this object has been deleted. Instances that have been deleted in the current transaction return true.

Transient instances return false.

see
PersistenceManager#deletePersistent(Object pc)
return
true if this instance was deleted in the current transaction.

public booleanjdoIsDirty()
Tests whether this object is dirty. Instances that have been modified, deleted, or newly made persistent in the current transaction return true.

Transient instances return false.

see
#jdoMakeDirty(String fieldName)
return
true if this instance has been modified in the current transaction.

public booleanjdoIsNew()
Tests whether this object has been newly made persistent. Instances that have been made persistent in the current transaction return true.

Transient instances return false.

see
PersistenceManager#makePersistent(Object pc)
return
true if this instance was made persistent in the current transaction.

public booleanjdoIsPersistent()
Tests whether this object is persistent. Instances whose state is stored in the data store return true.

Transient instances return false.

see
PersistenceManager#makePersistent(Object pc)
return
true if this instance is persistent.

public booleanjdoIsTransactional()
Tests whether this object is transactional. Instances that respect transaction boundaries return true. These instances include transient instances made transactional as a result of being the target of a makeTransactional method call; newly made persistent or deleted persistent instances; persistent instances read in data store transactions; and persistent instances modified in optimistic transactions.

Transient instances return false.

return
true if this instance is transactional.

public voidjdoMakeDirty(java.lang.String fieldName)
Explicitly mark this instance and this field dirty. Normally, PersistenceCapable classes are able to detect changes made to their fields. However, if a reference to an Array is given to a method outside the class, and the Array is modified, then the persistent instance is not aware of the change. This API allows the application to notify the instance that a change was made to a field.

Transient instances ignore this method.

param
fieldName the name of the field to be marked dirty.