Class PersistenceManagerWrapper
- java.lang.Object
-
- com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerWrapper
-
- All Implemented Interfaces:
PersistenceManager
public class PersistenceManagerWrapper extends Object implements PersistenceManager
PersistenceManagerWrapper is ....
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()A PersistenceManager instance can be used until it is closed.TransactioncurrentTransaction()There is exactly one Transaction associated with a PersistenceManager.voiddeletePersistent(Object pc)Delete the persistent instance from the data store.voiddeletePersistent(Object[] pcs)Delete an array of instances from the data store.voiddeletePersistent(Collection pcs)Delete a Collection of instances from the data store.CollectiongetExtent(Class persistenceCapableClass, boolean subclasses)The PersistenceManager may manage a collection of instances in the data store based on the class of the instances.ObjectgetObjectById(Object oid)This method locates a persistent instance in the cache of instances managed by this PersistenceManager.ObjectgetObjectById(Object oid, boolean validate)This method locates a persistent instance in the cache of instances managed by thisPersistenceManager.ObjectgetObjectId(Object pc)The ObjectId returned by this method represents the JDO identity of the instance.ClassgetObjectIdClass(Class cls)In order for the application to construct instance of the ObjectId class it needs to know the class being used by the JDO implementation.PersistenceManagergetPersistenceManager()PersistenceManagerFactorygetPersistenceManagerFactory()This method returns the PersistenceManagerFactory used to create this PersistenceManager.PropertiesgetProperties()The JDO vendor might store certain non-operational properties and make those properties available to applications (for troubleshooting).booleangetRequireCopyObjectId()Returns the boolean value of the requireCopyObjectId flag for this PersistenceManager.booleangetRequireTrackedSCO()Returns the boolean value of the requireTrackedSCO flag for this PersistenceManager.booleangetSupersedeDeletedInstance()Returns the boolean value of the supersedeDeletedInstance flag for this PersistenceManager.ObjectgetTransactionalInstance(Object pc)This method is used to get a PersistenceCapable instance representing the same data store object as the parameter, that is valid for this PersistenceManager.ObjectgetUserObject()The application can manage the PersistenceManager instances more easily by having an application object associated with each PersistenceManager instance.booleanisClosed()A PersistenceManager instance can be used until it is closed.voidmakePersistent(Object pc)Make the transient instance persistent in this PersistenceManager.voidmakePersistent(Object[] pcs)Make an array of instances persistent.voidmakePersistent(Collection pcs)Make a Collection of instances persistent.ObjectnewCollectionInstance(Class type, Object owner, String fieldName, Class elementType, boolean allowNulls, int initialSize)Returns a new Collection instance of the type specified, with the owner and field name to notify upon changes to the value of any of its fields.QuerynewQuery()Create a new Query with no elements.QuerynewQuery(Class cls)Create a new Query specifying the Class of the results.QuerynewQuery(Class cls, String filter)Create a new Query with the Class of the results and Filter.QuerynewQuery(Class cls, Collection cln)Create a new Query with the Class of the results and candidate Collection.QuerynewQuery(Class cls, Collection cln, String filter)Create a new Query with the Class of the results, candidate Collection, and Filter.QuerynewQuery(Object compiled)Create a new Query using elements from another Query.ObjectnewSCOInstance(Class type, Object owner, String fieldName)Returns a new Second Class Object instance of the type specified, with the owner and field name to notify upon changes to the value of any of its fields.voidsetRequireCopyObjectId(boolean flag)Sets the requireCopyObjectId flag for this PersistenceManager.voidsetRequireTrackedSCO(boolean flag)Sets the requireTrackedSCO flag for this PersistenceManager.voidsetSupersedeDeletedInstance(boolean flag)Sets the supersedeDeletedInstance flag for this PersistenceManager.voidsetUserObject(Object o)The application can manage the PersistenceManager instances more easily by having an application object associated with each PersistenceManager instance.
-
-
-
Method Detail
-
isClosed
public boolean isClosed()
A PersistenceManager instance can be used until it is closed.- Specified by:
isClosedin interfacePersistenceManager- Returns:
- if this PersistenceManager has been closed
- See Also:
close()
-
close
public void close()
A PersistenceManager instance can be used until it is closed.This method closes the PersistenceManager, which if pooled, releases it to the pool of available PersistenceManagers.
- Specified by:
closein interfacePersistenceManager
-
currentTransaction
public Transaction currentTransaction()
There is exactly one Transaction associated with a PersistenceManager.- Specified by:
currentTransactionin interfacePersistenceManager- Returns:
- the Transaction associated with this PersistenceManager.
-
newQuery
public Query newQuery()
Create a new Query with no elements.- Specified by:
newQueryin interfacePersistenceManager- Returns:
- a new Query instance with no elements.
-
newQuery
public Query newQuery(Object compiled)
Create a new Query using elements from another Query. The other Query must have been created by the same JDO implementation. It might be active in a different PersistenceManager or might have been serialized and restored.- Specified by:
newQueryin interfacePersistenceManager- Parameters:
compiled- another Query from the same JDO implementation- Returns:
- the new Query
-
newQuery
public Query newQuery(Class cls)
Create a new Query specifying the Class of the results.- Specified by:
newQueryin interfacePersistenceManager- Parameters:
cls- the Class of the results- Returns:
- the new Query
-
newQuery
public Query newQuery(Class cls, Collection cln)
Create a new Query with the Class of the results and candidate Collection. specified.- Specified by:
newQueryin interfacePersistenceManager- Parameters:
cls- the Class of resultscln- the Collection of candidate instances- Returns:
- the new Query
-
newQuery
public Query newQuery(Class cls, String filter)
Create a new Query with the Class of the results and Filter. specified.- Specified by:
newQueryin interfacePersistenceManager- Parameters:
cls- the Class of resultsfilter- the Filter for candidate instances- Returns:
- the new Query
-
newQuery
public Query newQuery(Class cls, Collection cln, String filter)
Create a new Query with the Class of the results, candidate Collection, and Filter.- Specified by:
newQueryin interfacePersistenceManager- Parameters:
cls- the Class of resultscln- the Collection of candidate instancesfilter- the Filter for candidate instances- Returns:
- the new Query
-
getExtent
public Collection getExtent(Class persistenceCapableClass, boolean subclasses)
The PersistenceManager may manage a collection of instances in the data store based on the class of the instances. This method returns a Collection of instances in the data store that might be iterated or given to a Query as the Collection of candidate instances.- Specified by:
getExtentin interfacePersistenceManager- Parameters:
persistenceCapableClass- Class of instancessubclasses- whether to include instances of subclasses- Returns:
- a Collection of instances
- See Also:
Query
-
getObjectById
public Object getObjectById(Object oid)
This method locates a persistent instance in the cache of instances managed by this PersistenceManager. If an instance with the same ObjectId is found it is returned. Otherwise, a new instance is created and associated with the ObjectId.If the instance does not exist in the data store, then this method will not fail. However, a request to access fields of the instance will throw an exception.
- Specified by:
getObjectByIdin interfacePersistenceManager- Parameters:
oid- an ObjectId- Returns:
- the PersistenceCapable instance with the specified ObjectId
-
getObjectById
public Object getObjectById(Object oid, boolean validate)
This method locates a persistent instance in the cache of instances managed by thisPersistenceManager. ThegetObjectByIdmethod attempts to find an instance in the cache with the specified JDO identity. Theoidparameter object might have been returned by an earlier call togetObjectIdor might have been constructed by the application.If the
PersistenceManageris unable to resolve theoidparameter to an ObjectId instance, then it throws aJDOUserException.If the
validateflag isfalse, and there is already an instance in the cache with the same JDO identity as theoidparameter, then this method returns it. There is no change made to the state of the returned instance.If there is not an instance already in the cache with the same JDO identity as the
oidparameter, then this method creates an instance with the specified JDO identity and returns it. If there is no transaction in progress, the returned instance will be hollow or persistent-nontransactional, at the choice of the implementation.If there is a transaction in progress, the returned instance will be hollow, persistent-nontransactional, or persistent-clean, at the choice of the implementation.
- Specified by:
getObjectByIdin interfacePersistenceManager- Parameters:
oid- an ObjectIdvalidate- if the existence of the instance is to be validated- Returns:
- the
PersistenceCapableinstance with the specified ObjectId - See Also:
getObjectId(Object pc)
-
getObjectId
public 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.- Specified by:
getObjectIdin interfacePersistenceManager- Parameters:
pc- the PersistenceCapable instance- Returns:
- the ObjectId of the instance
-
getTransactionalInstance
public Object getTransactionalInstance(Object pc)
This method is used to get a PersistenceCapable instance representing the same data store object as the parameter, that is valid for this PersistenceManager.- Specified by:
getTransactionalInstancein interfacePersistenceManager- Parameters:
pc- a PersistenceCapable instance- Returns:
- the PersistenceCapable instance representing the same data store object
-
makePersistent
public void makePersistent(Object pc)
Make the transient instance persistent in this PersistenceManager. This method must be called in an active transaction. The PersistenceManager assigns an ObjectId to the instance and transitions it to persistent-new. The instance will be managed in the Extent associated with its Class. The instance will be put into the data store at commit.- Specified by:
makePersistentin interfacePersistenceManager- Parameters:
pc- a transient instance of a Class that implements PersistenceCapable
-
makePersistent
public void makePersistent(Object[] pcs)
Make an array of instances persistent.- Specified by:
makePersistentin interfacePersistenceManager- Parameters:
pcs- an array of transient instances- See Also:
makePersistent(Object pc)
-
makePersistent
public void makePersistent(Collection pcs)
Make a Collection of instances persistent.- Specified by:
makePersistentin interfacePersistenceManager- Parameters:
pcs- a Collection of transient instances- See Also:
makePersistent(Object pc)
-
deletePersistent
public void deletePersistent(Object pc)
Delete the persistent instance from the data store. This method must be called in an active transaction. The data store object will be removed at commit. Unlike makePersistent, which makes the closure of the instance persistent, the closure of the instance is not deleted from the data store. This method has no effect if the instance is already deleted in the current transaction. This method throws an exception if the instance is transient or is managed by another PersistenceManager.- Specified by:
deletePersistentin interfacePersistenceManager- Parameters:
pc- a persistent instance
-
deletePersistent
public void deletePersistent(Object[] pcs)
Delete an array of instances from the data store.- Specified by:
deletePersistentin interfacePersistenceManager- Parameters:
pcs- a Collection of persistent instances- See Also:
deletePersistent(Object pc)
-
deletePersistent
public void deletePersistent(Collection pcs)
Delete a Collection of instances from the data store.- Specified by:
deletePersistentin interfacePersistenceManager- Parameters:
pcs- a Collection of persistent instances- See Also:
deletePersistent(Object pc)
-
getPersistenceManagerFactory
public PersistenceManagerFactory getPersistenceManagerFactory()
This method returns the PersistenceManagerFactory used to create this PersistenceManager. It returns null if this instance was created via a constructor.- Specified by:
getPersistenceManagerFactoryin interfacePersistenceManager- Returns:
- the PersistenceManagerFactory that created this PersistenceManager
-
setUserObject
public void setUserObject(Object o)
The application can manage the PersistenceManager instances more easily by having an application object associated with each PersistenceManager instance.- Specified by:
setUserObjectin interfacePersistenceManager- Parameters:
o- the user instance to be remembered by the PersistenceManager- See Also:
getUserObject()
-
getUserObject
public Object getUserObject()
The application can manage the PersistenceManager instances more easily by having an application object associated with each PersistenceManager instance.- Specified by:
getUserObjectin interfacePersistenceManager- Returns:
- the user object associated with this PersistenceManager
- See Also:
setUserObject(java.lang.Object)
-
getProperties
public Properties getProperties()
The JDO vendor might store certain non-operational properties and make those properties available to applications (for troubleshooting).Standard properties include:
- VendorName
- VersionNumber
- Specified by:
getPropertiesin interfacePersistenceManager- Returns:
- the Properties of this PersistenceManager
-
getSupersedeDeletedInstance
public boolean getSupersedeDeletedInstance()
Returns the boolean value of the supersedeDeletedInstance flag for this PersistenceManager. If set to true, deleted instances are allowed to be replaced with persistent-new instances with the equal Object Id.- Specified by:
getSupersedeDeletedInstancein interfacePersistenceManager- Returns:
- boolean supersedeDeletedInstance flag
-
setSupersedeDeletedInstance
public void setSupersedeDeletedInstance(boolean flag)
Sets the supersedeDeletedInstance flag for this PersistenceManager.- Specified by:
setSupersedeDeletedInstancein interfacePersistenceManager- Parameters:
flag- boolean supersedeDeletedInstance flag
-
getRequireCopyObjectId
public boolean getRequireCopyObjectId()
Returns the boolean value of the requireCopyObjectId flag for this PersistenceManager. If set to false, the PersistenceManager does not create a copy of an ObjectId forPersistenceManager.getObjectId(Object pc)andPersistenceManager.getObjectById(Object oid)requests.- Specified by:
getRequireCopyObjectIdin interfacePersistenceManager- Returns:
- boolean requireCopyObjectId flag
- See Also:
PersistenceManager.getObjectId(Object pc),PersistenceManager.getObjectById(Object oid)
-
setRequireCopyObjectId
public void setRequireCopyObjectId(boolean flag)
Sets the requireCopyObjectId flag for this PersistenceManager. If set to false, the PersistenceManager will not create a copy of an ObjectId forPersistenceManager.getObjectId(Object pc)andPersistenceManager.getObjectById(Object oid)requests.- Specified by:
setRequireCopyObjectIdin interfacePersistenceManager- Parameters:
flag- boolean requireCopyObjectId flag- See Also:
PersistenceManager.getObjectId(Object pc),PersistenceManager.getObjectById(Object oid)
-
getRequireTrackedSCO
public boolean getRequireTrackedSCO()
Returns the boolean value of the requireTrackedSCO flag for this PersistenceManager. If set to false, the PersistenceManager will not create tracked SCO instances for new persistent instances at commit with retainValues set to true and while retrieving data from a datastore.- Specified by:
getRequireTrackedSCOin interfacePersistenceManager- Returns:
- boolean requireTrackedSCO flag
-
setRequireTrackedSCO
public void setRequireTrackedSCO(boolean flag)
Sets the requireTrackedSCO flag for this PersistenceManager. If set to false, the PersistenceManager will not create tracked SCO instances for new persistent instances at commit with retainValues set to true and while retrieving data from a datastore.- Specified by:
setRequireTrackedSCOin interfacePersistenceManager- Parameters:
flag- boolean requireTrackedSCO flag
-
getObjectIdClass
public Class getObjectIdClass(Class cls)
In order for the application to construct instance of the ObjectId class it needs to know the class being used by the JDO implementation.- Specified by:
getObjectIdClassin interfacePersistenceManager- Parameters:
cls- the PersistenceCapable Class- Returns:
- the Class of the ObjectId of the parameter
-
newSCOInstance
public Object newSCOInstance(Class type, Object owner, String fieldName)
Returns a new Second Class Object instance of the type specified, with the owner and field name to notify upon changes to the value of any of its fields. If a collection class is created, then the class does not restrict the element types, and allows nulls to be added as elements.- Specified by:
newSCOInstancein interfacePersistenceManager- Parameters:
type- Class of the new SCO instanceowner- the owner to notify upon changesfieldName- the field to notify upon changes- Returns:
- the object of the class type
-
newCollectionInstance
public Object newCollectionInstance(Class type, Object owner, String fieldName, Class elementType, boolean allowNulls, int initialSize)
Returns a new Collection instance of the type specified, with the owner and field name to notify upon changes to the value of any of its fields. The collection class restricts the element types allowed to the elementType or instances assignable to the elementType, and allows nulls to be added as elements based on the setting of allowNulls. The Collection has an initial size as specified by the initialSize parameter.- Specified by:
newCollectionInstancein interfacePersistenceManager- Parameters:
type- Class of the new SCO instanceowner- the owner to notify upon changesfieldName- the field to notify upon changeselementType- the element types allowedallowNulls- true if allowedinitialSize- initial size of the Collection- Returns:
- the object of the class type
-
getPersistenceManager
public PersistenceManager getPersistenceManager()
-
-