Class JDOHelper
java.lang.Object
com.sun.jdo.api.persistence.support.JDOHelper
An utility class for querying
PersistenceCapable objects.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetObjectId(Object obj) Returns a copy of the JDO identity associated with an object.static PersistenceManagerReturns the associated PersistenceManager of an object if there is one.static booleanTests whether the object has been deleted.static booleanTests whether an object is dirty.static booleanTests whether the object has been newly made persistent.static booleanisPersistent(Object obj) Tests whether an object is persistent.static booleanisTransactional(Object obj) Tests whether an object is transactional.static voidExplicitly marks a field of an object as dirty if the object is persistent and transactional.static StringPrints the object.
-
Constructor Details
-
JDOHelper
public JDOHelper()
-
-
Method Details
-
getPersistenceManager
Returns the associated PersistenceManager of an object if there is one. For transactional and persistent objects, their associatedPersistenceManageris returned. For transient objects,nullis returned.- Parameters:
obj- anObject- Returns:
- the PersistenceManager associated with the object;
nullotherwise - See Also:
-
makeDirty
Explicitly marks a field of an object as dirty if the object is persistent and transactional. 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 object is not aware of the change. This method allows the application to notify the object that a change was made to a field. For transient objects, this method does nothing.- Parameters:
obj- an objectfieldName- the name of the object's field to be marked dirty- See Also:
-
getObjectId
Returns a copy of the JDO identity associated with an object. Persistent objects of PersistenceCapable classes have a JDO identity managed by the PersistenceManager. This method returns a copy of the ObjectId that represents the JDO identity of a persistent object. For transient objects,nullis returned.The ObjectId may be serialized and later restored, and used with a PersistenceManager from the same JDO implementation to locate a persistent object 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.
- Parameters:
obj- anObject- Returns:
- a copy of the ObjectId of a persistent object;
nullif the object is transient - See Also:
-
isDirty
Tests whether an object is dirty. If the object have been modified, deleted, or newly made persistent in the current transaction,trueis returned. For transient objects,falseis returned.- Parameters:
obj- anObject- Returns:
trueif the object has been modified in the current transaction;falseotherwise.- See Also:
-
isTransactional
Tests whether an object is transactional. For objects that respect transaction boundaries,trueis returned. These objects include transient objects made transactional as a result of being the target of a makeTransactional method call; newly made persistent or deleted persistent objects; persistent objects read in data store transactions; and persistent objects modified in optimistic transactions. For non-transactional objects,falseis returned.- Parameters:
obj- anObject- Returns:
trueif the object is transactional;falseotherwise.- See Also:
-
isPersistent
Tests whether an object is persistent. For objects whose state is stored in the data store,trueis returned. For transient objects,falseis returned.- Parameters:
obj- anObject- Returns:
trueif the object is persistent;falseotherwise.- See Also:
-
isNew
Tests whether the object has been newly made persistent. For objects that have been made persistent in the current transaction,trueis returned. For transient or objects,falseis returned.- Parameters:
obj- anObject- Returns:
trueif the object was made persistent in the current transaction;falseotherwise.- See Also:
-
isDeleted
Tests whether the object has been deleted. For objects that have been deleted in the current transaction,trueis returned. For transient objects,falseis returned.- Parameters:
obj- anObject- Returns:
trueif the object was deleted in the current transaction;falseotherwise.- See Also:
-
printObject
Prints the object. If object is not NULL and is not deleted, calls toString() method on the object. Does not allow to access fields of the deleted object
-