Class JDOHelper
- java.lang.Object
-
- com.sun.jdo.api.persistence.support.JDOHelper
-
public class JDOHelper extends Object
An utility class for queryingPersistenceCapableobjects.
-
-
Constructor Summary
Constructors Constructor Description JDOHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectgetObjectId(Object obj)Returns a copy of the JDO identity associated with an object.static PersistenceManagergetPersistenceManager(Object obj)Returns the associated PersistenceManager of an object if there is one.static booleanisDeleted(Object obj)Tests whether the object has been deleted.static booleanisDirty(Object obj)Tests whether an object is dirty.static booleanisNew(Object obj)Tests 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 voidmakeDirty(Object obj, String fieldName)Explicitly marks a field of an object as dirty if the object is persistent and transactional.static StringprintObject(Object o)Prints the object.
-
-
-
Method Detail
-
getPersistenceManager
public static PersistenceManager getPersistenceManager(Object obj)
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:
PersistenceCapable.jdoGetPersistenceManager()
-
makeDirty
public static void makeDirty(Object obj, String fieldName)
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:
PersistenceCapable.jdoMakeDirty(String fieldName)
-
getObjectId
public static Object getObjectId(Object obj)
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:
PersistenceCapable.jdoGetObjectId(),PersistenceManager.getObjectId(Object obj),PersistenceManager.getObjectById(Object oid)
-
isDirty
public static boolean isDirty(Object obj)
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:
PersistenceCapable.jdoIsDirty(),PersistenceCapable.jdoMakeDirty(String fieldName)
-
isTransactional
public static boolean isTransactional(Object obj)
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:
PersistenceCapable.jdoIsTransactional()
-
isPersistent
public static boolean isPersistent(Object obj)
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:
PersistenceCapable.jdoIsPersistent(),PersistenceManager.makePersistent(Object obj)
-
isNew
public static boolean isNew(Object obj)
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:
PersistenceCapable.jdoIsNew(),PersistenceManager.makePersistent(Object obj)
-
isDeleted
public static boolean isDeleted(Object obj)
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:
PersistenceCapable.jdoIsDeleted(),PersistenceManager.deletePersistent(Object obj)
-
-