public interface PersistenceManager
A PersistenceManager is obtained from the
PersistenceManagerFactory
(recommended) or by construction.
Modifier and Type | Method and Description |
---|---|
void |
close()
A PersistenceManager instance can be used until it is closed.
|
Transaction |
currentTransaction()
There is exactly one Transaction associated with a PersistenceManager.
|
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.
|
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 |
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.
|
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 |
isClosed()
A PersistenceManager instance can be used until it is closed.
|
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.
|
Query |
newQuery()
Create a new Query with no elements.
|
Query |
newQuery(Class cls)
Create a new Query specifying the Class of the candidate instances.
|
Query |
newQuery(Class cls,
Collection cln)
Create a new Query with the Class of the candidate instances and candidate Collection.
|
Query |
newQuery(Class cls,
Collection cln,
String filter)
Create a new Query with the Class of the candidate instances, candidate Collection,
and Filter.
|
Query |
newQuery(Class cls,
String filter)
Create a new Query with the Class of the candidate instances 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.
|
void |
setRequireCopyObjectId(boolean flag)
Sets the requireCopyObjectId flag for this PersistenceManager.
|
void |
setRequireTrackedSCO(boolean flag)
Sets the requireTrackedSCO flag for this PersistenceManager.
|
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.
|
boolean isClosed()
close()
void close()
This method closes the PersistenceManager, which if pooled, releases it to the pool of available PersistenceManagers.
Transaction currentTransaction()
Query newQuery()
Query newQuery(Object compiled)
compiled
- another Query from the same JDO implementationQuery newQuery(Class cls)
cls
- the Class of the candidate instancesQuery newQuery(Class cls, Collection cln)
cls
- the Class of the candidate instancescln
- the Collection of candidate instancesQuery newQuery(Class cls, String filter)
cls
- the Class of the candidate instancesfilter
- the Filter for candidate instancesQuery newQuery(Class cls, Collection cln, String filter)
cls
- the Class of the candidate instancescln
- the Collection of candidate instancesfilter
- the Filter for candidate instancesCollection getExtent(Class persistenceCapableClass, boolean subclasses)
persistenceCapableClass
- Class of instancessubclasses
- whether to include instances of subclassesQuery
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.
oid
- an ObjectIdObject getObjectId(Object pc)
pc
- the PersistenceCapable instanceObject getTransactionalInstance(Object pc)
pc
- a PersistenceCapable instancevoid makePersistent(Object pc)
pc
- a transient instance of a Class that implements
PersistenceCapablevoid makePersistent(Object[] pcs)
pcs
- an array of transient instancesmakePersistent(Object pc)
void makePersistent(Collection pcs)
pcs
- a Collection of transient instancesmakePersistent(Object pc)
void deletePersistent(Object pc)
pc
- a persistent instancevoid deletePersistent(Object[] pcs)
pcs
- a Collection of persistent instancesdeletePersistent(Object pc)
void deletePersistent(Collection pcs)
pcs
- a Collection of persistent instancesdeletePersistent(Object pc)
PersistenceManagerFactory getPersistenceManagerFactory()
void setUserObject(Object o)
o
- the user instance to be remembered by the PersistenceManagergetUserObject()
Object getUserObject()
setUserObject(java.lang.Object)
Properties getProperties()
Standard properties include:
Class getObjectIdClass(Class cls)
cls
- the PersistenceCapable ClassObject newSCOInstance(Class type, Object owner, String fieldName)
type
- Class of the new SCO instanceowner
- the owner to notify upon changesfieldName
- the field to notify upon changesObject newCollectionInstance(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 CollectionObject getObjectById(Object oid, boolean validate)
PersistenceManager
.
The getObjectById
method attempts
to find an instance in the cache with the specified JDO identity.
The oid
parameter object might have been returned by an earlier call
to getObjectId
or might have been constructed by the application.
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 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.
It is an implementation decision whether to access the data store,
if required to determine the exact class. This will be the case of
inheritance, where multiple PersistenceCapable
classes share the
same ObjectId class.
If the validate flag is false
, and the instance does not exist in
the data store, then this method might not fail. It is an
implementation choice whether to fail immediately with a
JDODataStoreException
. But a subsequent access of the fields of the
instance will throw a JDODataStoreException
if the instance does not
exist at that time. Further, if a relationship is established to this
instance, then the transaction in which the association was made will
fail.
If the validate
flag is true
, and there is already a transactional
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 an instance already in the cache with the same JDO
identity as the oid
parameter, but the instance is not transactional,
then it must be verified in the data store. If the instance does not
exist in the datastore, then a JDODataStoreException
is thrown.
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, verifies that it exists in the data
store, 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 data store transaction in progress, the returned instance will be persistent-clean. If there is an optimistic transaction in progress, the returned instance will be persistent-nontransactional.
oid
- an ObjectIdvalidate
- if the existence of the instance is to be validatedPersistenceCapable
instance with the specified ObjectIdgetObjectId(Object pc)
,
getObjectById(Object oid)
boolean getSupersedeDeletedInstance()
void setSupersedeDeletedInstance(boolean flag)
flag
- boolean supersedeDeletedInstance flagboolean getRequireCopyObjectId()
PersistenceManager.getObjectId(Object pc)
and PersistenceManager.getObjectById(Object oid)
requests.getObjectId(Object pc)
,
getObjectById(Object oid)
void setRequireCopyObjectId(boolean flag)
PersistenceManager.getObjectId(Object pc)
and PersistenceManager.getObjectById(Object oid)
requests.flag
- boolean requireCopyObjectId flaggetObjectId(Object pc)
,
getObjectById(Object oid)
boolean getRequireTrackedSCO()
void setRequireTrackedSCO(boolean flag)
flag
- boolean requireTrackedSCO flagCopyright © 2018. All rights reserved.