public class PersistenceManagerImpl extends Object implements PersistenceManager
| Modifier and Type | Method and Description |
|---|---|
void |
acquireCacheLock()
Lock cache for getObjectById and result processing synchronization.
|
void |
acquireExclusiveLock()
Acquires an exclusive lock from the persistence manager.
|
void |
acquireFieldUpdateLock()
Acquire lock for synchronizing field updates.
|
void |
acquireShareLock()
Acquires a share lock from the persistence manager.
|
void |
afterCompletion(int status)
Called by Transaction commit() or rollback()
cleans up transactional cache
|
void |
beforeCompletion()
Called by Transaction commit().
|
void |
clearFields(Object pc) |
void |
close()
close the persistence manager
|
Transaction |
currentTransaction()
Returns transaction associated with this persistence manager
|
void |
deletePersistent(Collection pcs)
Delete a Collection of instances from the data store.
|
void |
deletePersistent(Object pc)
Delete the persistent instance from the data store.
|
void |
deletePersistent(Object[] pcs)
Delete an array of instances from the data store.
|
void |
deregisterInstance(Object oid)
Deregister an instance.
|
void |
deregisterInstance(Object oid,
StateManager sm)
Deregister an instance with this object Id, only if it holds the same instance.
|
StateManager |
findOrCreateStateManager(Object oid,
Class pcClass)
Called internally by
RetrieveDesc to lookup an instance
in the cache, or prepare new instance to be populated with values from the datastore. |
void |
forceClose()
Force to close the persistence manager.
|
PersistenceManagerWrapper |
getCurrentWrapper() |
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.
|
Object |
getField(Object pc,
int fieldNumber) |
byte |
getFlags(Object pc) |
protected boolean |
getIgnoreCache() |
Object |
getObjectById(Object oid)
This method locates a persistent instance in the cache of instances
managed by this PersistenceManager.
|
Object |
getObjectById(Object oid,
boolean validate)
This method locates a persistent instance in the cache of instances
managed by this
PersistenceManager. |
Object |
getObjectId(Object pc)
The ObjectId returned by this method represents the JDO identity of
the instance.
|
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.
|
PersistenceManagerFactory |
getPersistenceManagerFactory()
This method returns the PersistenceManagerFactory used to create
this PersistenceManager.
|
Properties |
getProperties()
The JDO vendor might store certain non-operational properties and
make those properties available to applications (for troubleshooting).
|
boolean |
getRequireCopyObjectId()
Returns the boolean value of the requireCopyObjectId flag
for this PersistenceManager.
|
boolean |
getRequireTrackedSCO()
Returns the boolean value of the requireTrackedSCO flag
for this PersistenceManager.
|
RetrieveDesc |
getRetrieveDesc(Class classType)
Return a RetrieveDesc given a Class object.
|
RetrieveDesc |
getRetrieveDesc(String fieldName,
Class classType)
Return a RetrieveDesc for a foreign field (relationship) given the
Class object for the parent class.
|
StateManager |
getStateManager(Object pc) |
protected PersistenceStore |
getStore() |
boolean |
getSupersedeDeletedInstance()
Returns the boolean value of the supersedeDeletedInstance flag
for this PersistenceManager.
|
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.
|
Object |
getUserObject()
The application can manage the PersistenceManager instances
more easily by having an application object associated with each
PersistenceManager instance.
|
boolean |
initializeFromVersionConsistencyCache(StateManager sm)
Looks up the given instance in the Version Consistency cache and
if found, populates it from the cached values.
|
void |
internalFlush()
Called by Query to flush updates to the database
in pessimistic transaction.
|
boolean |
isActiveTransaction()
Returns true if associated transaction is active
|
boolean |
isClosed()
A PersistenceManager instance can be used until it is closed.
|
boolean |
isNontransactionalRead()
Returns true if associated transaction is optimistic
|
boolean |
isOptimisticTransaction()
Returns true if associated transaction is optimistic
|
void |
makePersistent(Collection pcs)
Make a Collection of instances persistent.
|
void |
makePersistent(Object pc)
Make the transient instance persistent in this PersistenceManager.
|
void |
makePersistent(Object[] pcs)
Make an array of instances persistent.
|
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.
|
Object |
newCollectionInstanceInternal(Class type,
Object owner,
String fieldName,
Class elementType,
boolean allowNulls,
int initialSize)
Called by newCollectionInstance from the public interface or internally
by the runtime
Will not result in marking field as dirty
|
Object |
newInstance(StateManager sm)
Returns a new instance of the object defined by the given
StateManager
|
Query |
newQuery()
Create a new Query with no elements.
|
Query |
newQuery(Class cls)
Create a new Query specifying the Class of the results.
|
Query |
newQuery(Class cls,
Collection cln)
Create a new Query with the Class of the results and candidate Collection.
|
Query |
newQuery(Class cls,
Collection cln,
String filter)
Create a new Query with the Class of the results, candidate Collection,
and Filter.
|
Query |
newQuery(Class cls,
String filter)
Create a new Query with the Class of the results and Filter.
|
Query |
newQuery(Object compiled)
Create a new Query using elements from another Query.
|
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.
|
Object |
newSCOInstanceInternal(Class type,
Object owner,
String fieldName)
Called by newSCOInstance from the public interface or internally
by the runtime
Will not result in marking field as dirty
Returns a new Second Class Object instance of the type specified,
|
void |
notifyNontransactionalRead(boolean nontransactionalRead)
For Transaction to notify PersistenceManager that
nontransactionalRead flag is changed
|
void |
notifyOptimistic(boolean optimistic)
For Transaction to notify PersistenceManager that
optimistic flag is changed
|
void |
notifyStatusChange(boolean isActive)
For Transaction to notify PersistenceManager that
status is changed
|
protected void |
popCurrentWrapper(PersistenceManagerWrapper prev) |
protected void |
pushCurrentWrapper(PersistenceManagerWrapper pmw) |
void |
registerInstance(StateManager sm,
Object oid)
Register instance in the weak cache only.
|
void |
registerInstance(StateManager sm,
Object oid,
boolean throwDuplicateException,
boolean forceRegister)
Register instance in the transactional cache
|
void |
releaseCacheLock()
Release cache lock.
|
void |
releaseExclusiveLock()
Release the exclusive lock and notify any thread waiting to get an exclusive or
share lock.
|
void |
releaseFieldUpdateLock()
Release lock for synchronizing field updates.
|
void |
releaseShareLock()
Releases the share lock and notify any thread waiting to get an exclusive lock.
|
Object |
retrieve(RetrieveDesc action)
Executes the given retrieve descriptor.
|
Object |
retrieve(RetrieveDesc action,
ValueFetcher parameters)
Executes the given retrieve descriptor.
|
void |
setField(Object o,
int fieldNumber,
Object value) |
void |
setFlags(Object pc,
byte flags) |
protected void |
setJTATransaction(Transaction t)
Assigns reference to javax.transaction.Transaction associated
with the current thread in the managed environment
|
void |
setRequireCopyObjectId(boolean flag)
Sets the requireCopyObjectId flag for this PersistenceManager.
|
void |
setRequireTrackedSCO(boolean flag)
Sets the requireTrackedSCO flag for this PersistenceManager.
|
void |
setStateManager(Object pc,
StateManager sm) |
protected void |
setStore(PersistenceStore store) |
void |
setSupersedeDeletedInstance(boolean flag)
Sets the supersedeDeletedInstance flag for this PersistenceManager.
|
void |
setUserObject(Object o)
The application can manage the PersistenceManager instances
more easily by having an application object associated with each
PersistenceManager instance.
|
protected boolean |
verify(String username,
String password) |
protected void setStore(PersistenceStore store)
protected PersistenceStore getStore()
protected boolean getIgnoreCache()
public boolean isClosed()
PersistenceManagerisClosed in interface PersistenceManagerPersistenceManager.close()public void forceClose()
public void close()
close in interface PersistenceManagerpublic Transaction currentTransaction()
currentTransaction in interface PersistenceManagerpublic Query newQuery()
newQuery in interface PersistenceManagerpublic Query newQuery(Object compiled)
newQuery in interface PersistenceManagercompiled - another Query from the same JDO implementationpublic Query newQuery(Class cls)
newQuery in interface PersistenceManagercls - the Class of the resultspublic Query newQuery(Class cls, Collection cln)
newQuery in interface PersistenceManagercls - the Class of resultscln - the Collection of candidate instancespublic Query newQuery(Class cls, String filter)
newQuery in interface PersistenceManagercls - the Class of resultsfilter - the Filter for candidate instancespublic Query newQuery(Class cls, Collection cln, String filter)
newQuery in interface PersistenceManagercls - the Class of resultscln - the Collection of candidate instancesfilter - the Filter for candidate instancespublic Collection getExtent(Class persistenceCapableClass, boolean subclasses)
getExtent in interface PersistenceManagerpersistenceCapableClass - Class of instancessubclasses - whether to include instances of subclassesnewQuery()public Object getObjectById(Object oid)
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.
getObjectById in interface PersistenceManageroid - an ObjectIdgetObjectById(Object, boolean)public Object getObjectById(Object oid, boolean validate)
PersistenceManager.
The getObjectByIdInternal method attempts
to find an instance in the cache with the specified JDO identity.
If the PersistenceManager is unable to resolve the oid parameter
to an ObjectId instance, then it throws a JDOUserException.
If the validate flag is false, and there is already an instance in the
cache with the same JDO identity as the oid parameter, 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 oid parameter, 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.
If there is a transaction in progress, the returned instance will persistent-nontransactional in an optimistic transaction, or persistent-clean in a datastore transaction.
getObjectById in interface PersistenceManageroid - an ObjectIdvalidate - if the existence of the instance is to be validatedPersistenceCapable instance with the specified ObjectIdPersistenceManager.getObjectId(Object pc),
PersistenceManager.getObjectById(Object oid)public StateManager findOrCreateStateManager(Object oid, Class pcClass)
RetrieveDesc to lookup an instance
in the cache, or prepare new instance to be populated with values from the datastore.oid - an ObjectIdpcClass - the Class type of the PersistenceCapable instance to be associated
with this StateManager.StateManager instance with the specified ObjectIdpublic Object getObjectId(Object pc)
getObjectId in interface PersistenceManagerpc - the PersistenceCapable instancepublic Object getTransactionalInstance(Object pc)
getTransactionalInstance in interface PersistenceManagerpc - a PersistenceCapable instancepublic void makePersistent(Object pc)
makePersistent in interface PersistenceManagerpc - a transient instance of a Class that implements
PersistenceCapablepublic void makePersistent(Object[] pcs)
makePersistent in interface PersistenceManagerpcs - an array of transient instancesmakePersistent(Object pc)public void makePersistent(Collection pcs)
PersistenceManagermakePersistent in interface PersistenceManagerpcs - a Collection of transient instancesPersistenceManager.makePersistent(Object pc)public void deletePersistent(Object pc)
PersistenceManagerdeletePersistent in interface PersistenceManagerpc - a persistent instancepublic void deletePersistent(Object[] pcs)
PersistenceManagerdeletePersistent in interface PersistenceManagerpcs - a Collection of persistent instancesPersistenceManager.deletePersistent(Object pc)public void deletePersistent(Collection pcs)
PersistenceManagerdeletePersistent in interface PersistenceManagerpcs - a Collection of persistent instancesPersistenceManager.deletePersistent(Object pc)public PersistenceManagerFactory getPersistenceManagerFactory()
getPersistenceManagerFactory in interface PersistenceManagerpublic void setUserObject(Object o)
setUserObject in interface PersistenceManagero - the user instance to be remembered by the PersistenceManagergetUserObject()public Object getUserObject()
getUserObject in interface PersistenceManagersetUserObject(java.lang.Object)public Properties getProperties()
Standard properties include:
getProperties in interface PersistenceManagerpublic boolean getSupersedeDeletedInstance()
getSupersedeDeletedInstance in interface PersistenceManagerpublic void setSupersedeDeletedInstance(boolean flag)
setSupersedeDeletedInstance in interface PersistenceManagerflag - boolean supersedeDeletedInstance flagpublic boolean getRequireCopyObjectId()
PersistenceManager.getObjectId(Object pc)
and PersistenceManager.getObjectById(Object oid) requests.getRequireCopyObjectId in interface PersistenceManagerPersistenceManager.getObjectId(Object pc),
PersistenceManager.getObjectById(Object oid)public void setRequireCopyObjectId(boolean flag)
PersistenceManager.getObjectId(Object pc)
and PersistenceManager.getObjectById(Object oid) requests.setRequireCopyObjectId in interface PersistenceManagerflag - boolean requireCopyObjectId flagPersistenceManager.getObjectId(Object pc),
PersistenceManager.getObjectById(Object oid)public boolean getRequireTrackedSCO()
getRequireTrackedSCO in interface PersistenceManagerpublic void setRequireTrackedSCO(boolean flag)
setRequireTrackedSCO in interface PersistenceManagerflag - boolean requireTrackedSCO flagpublic Class getObjectIdClass(Class cls)
getObjectIdClass in interface PersistenceManagercls - the PersistenceCapable Classpublic Object newInstance(StateManager sm)
sm - StateManagerpublic Object retrieve(RetrieveDesc action, ValueFetcher parameters)
action - The retrieve descriptor.parameters - The input parameters for the query.public Object retrieve(RetrieveDesc action)
action - The retrieve descriptor.public RetrieveDesc getRetrieveDesc(Class classType)
public RetrieveDesc getRetrieveDesc(String fieldName, Class classType)
public void registerInstance(StateManager sm, Object oid)
public void registerInstance(StateManager sm, Object oid, boolean throwDuplicateException, boolean forceRegister)
public void deregisterInstance(Object oid)
PersistenceManagerpublic void deregisterInstance(Object oid, StateManager sm)
PersistenceManagerpublic void beforeCompletion()
public void afterCompletion(int status)
status - javax.transaction.Statuspublic boolean initializeFromVersionConsistencyCache(StateManager sm)
PersistenceManagersm - Instance to be looked up in the version consistency cache.
If found, it is populated with values from the cache.sm was found and populated, false
otherwise.public void setStateManager(Object pc, StateManager sm)
public void setFlags(Object pc, byte flags)
public byte getFlags(Object pc)
public StateManager getStateManager(Object pc)
public void clearFields(Object pc)
public Object newSCOInstance(Class type, Object owner, String fieldName)
newSCOInstance in interface PersistenceManagertype - Class of the new SCO instanceowner - the owner to notify upon changesfieldName - the field to notify upon changespublic Object newSCOInstanceInternal(Class type, Object owner, String fieldName)
type - Class of the new SCO instanceowner - the owner to notify upon changesfieldName - the field to notify upon changespublic Object newCollectionInstance(Class type, Object owner, String fieldName, Class elementType, boolean allowNulls, int initialSize)
newCollectionInstance in interface PersistenceManagertype - 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 Collectionpublic Object newCollectionInstanceInternal(Class type, Object owner, String fieldName, Class elementType, boolean allowNulls, int initialSize)
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 Collectionfor more informationpublic void internalFlush()
beforeCompletion()public void notifyStatusChange(boolean isActive)
public void notifyOptimistic(boolean optimistic)
public boolean isOptimisticTransaction()
public void notifyNontransactionalRead(boolean nontransactionalRead)
public boolean isNontransactionalRead()
public boolean isActiveTransaction()
public PersistenceManagerWrapper getCurrentWrapper()
protected void pushCurrentWrapper(PersistenceManagerWrapper pmw)
protected void popCurrentWrapper(PersistenceManagerWrapper prev)
protected void setJTATransaction(Transaction t)
public void acquireShareLock()
public void releaseShareLock()
public void acquireExclusiveLock()
public void releaseExclusiveLock()
public void acquireFieldUpdateLock()
public void releaseFieldUpdateLock()
public void acquireCacheLock()
public void releaseCacheLock()
Copyright © 2017. All rights reserved.