public interface PersistenceCapable
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'.
Modifier and Type | Method and Description |
---|---|
Object |
jdoGetObjectId()
Return a copy of the JDO identity associated with this instance.
|
PersistenceManager |
jdoGetPersistenceManager()
Return the associated PersistenceManager if there is one.
|
boolean |
jdoIsDeleted()
Tests whether this object has been deleted.
|
boolean |
jdoIsDirty()
Tests whether this object is dirty.
|
boolean |
jdoIsNew()
Tests whether this object has been newly made persistent.
|
boolean |
jdoIsPersistent()
Tests whether this object is persistent.
|
boolean |
jdoIsTransactional()
Tests whether this object is transactional.
|
void |
jdoMakeDirty(String fieldName)
Explicitly mark this instance and this field dirty.
|
PersistenceManager jdoGetPersistenceManager()
Transient non-transactional instances return null.
void jdoMakeDirty(String fieldName)
Transient instances ignore this method.
fieldName
- the name of the field to be marked dirty.Object jdoGetObjectId()
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.
PersistenceManager.getObjectId(Object pc)
,
PersistenceManager.getObjectById(Object oid)
boolean jdoIsDirty()
Transient instances return false.
jdoMakeDirty(String fieldName)
boolean jdoIsTransactional()
Transient instances return false.
boolean jdoIsPersistent()
Transient instances return false.
PersistenceManager.makePersistent(Object pc)
boolean jdoIsNew()
Transient instances return false.
PersistenceManager.makePersistent(Object pc)
boolean jdoIsDeleted()
Transient instances return false.
PersistenceManager.deletePersistent(Object pc)
Copyright © 2018. All rights reserved.