org.datanucleus.jdo
Class JDOPersistenceManager

java.lang.Object
  extended by org.datanucleus.jdo.JDOPersistenceManager
All Implemented Interfaces:
javax.jdo.PersistenceManager

public class JDOPersistenceManager
extends java.lang.Object
implements javax.jdo.PersistenceManager

Provide the basics of a JDO PersistenceManager using an underlying ObjectManager to perform the actual persistence.


Field Summary
protected  JDOFetchPlan fetchPlan
          JDO Fetch Plan.
protected  javax.jdo.Transaction jdotx
           
protected static Localiser LOCALISER
          Localisation utility for output messages from core.
protected static Localiser LOCALISER_JDO
          Localisation utility for output messages from jdo.
static NucleusLogger LOGGER
          Logger for JDO.
protected  ObjectManager objectMgr
          Backing ObjectManager for this PersistenceManager.
protected  JDOPersistenceManagerFactory pmf
          Owning PersistenceManagerFactory.
 
Constructor Summary
JDOPersistenceManager(JDOPersistenceManagerFactory apmf, java.lang.String userName, java.lang.String password)
          Constructor.
 
Method Summary
 void addInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener listener, java.lang.Class... classes)
          Method to register a lifecycle listener as per JDO 2.0 spec 12.15.
protected  void assertActiveTransaction()
          Method to assert if the current transaction is active.
protected  void assertIsOpen()
          Method to assert if this Persistence Manager is open.
protected  void assertReadable(java.lang.String operation)
          Method to assert if no active transaction and nontransactionalRead is not set.
protected  void assertWritable()
          Method to assert if the current transaction is active or non transactional writes are allowed.
 void checkConsistency()
          This method validates the cache with the datastore.
 void close()
          Method to close the Persistence Manager.
 javax.jdo.Transaction currentTransaction()
          Accessor for the current transaction.
 void deletePersistent(java.lang.Object obj)
          JDO method to delete an object from the datastore.
 void deletePersistentAll(java.util.Collection pcs)
          JDO method to delete a collection of objects from the datastore.
 void deletePersistentAll(java.lang.Object... pcs)
          JDO method to delete an array of objects from the datastore.
 java.lang.Object detachCopy(java.lang.Object pc)
          JDO method to detach a persistent object.
 java.util.Collection detachCopyAll(java.util.Collection pcs)
          Detach the specified objects from the PersistenceManager.
 java.lang.Object[] detachCopyAll(java.lang.Object... pcs)
          Detach the specified objects from the PersistenceManager.
 void evict(java.lang.Object obj)
          Method to evict an object from L1 cache.
 void evictAll()
          Method to evict all current objects from L1 cache.
 void evictAll(boolean subclasses, java.lang.Class cls)
          Method to evict all objects of the specified type (and optionaly its subclasses).
 void evictAll(java.util.Collection pcs)
          Method to evict a collection of objects from L1 cache.
 void evictAll(java.lang.Object... pcs)
          Method to evict an array of objects from L1 cache.
 void flush()
          This method flushes all dirty, new, and deleted instances to the datastore.
 boolean getCopyOnAttach()
          Accessor for whether to copy objects on attaching.
 javax.jdo.datastore.JDOConnection getDataStoreConnection()
          Accessor for a connection on the datastore.
 java.lang.Integer getDatastoreReadTimeoutMillis()
          Accessor for the datastore read timeout (milliseconds).
 java.lang.Integer getDatastoreWriteTimeoutMillis()
          Accessor for the datastore write timeout (milliseconds).
 boolean getDetachAllOnCommit()
          Accessor for whether to detach all objects on commit of the transaction.
 javax.jdo.Extent getExtent(java.lang.Class pcClass)
          Extents are collections of datastore objects managed by the datastore, not by explicit user operations on collections.
 javax.jdo.Extent getExtent(java.lang.Class pcClass, boolean subclasses)
          Extents are collections of datastore objects managed by the datastore, not by explicit user operations on collections.
 javax.jdo.FetchGroup getFetchGroup(java.lang.Class cls, java.lang.String name)
          Method to return a fetch group for the specified class, with the specified name.
 javax.jdo.FetchPlan getFetchPlan()
          Acessor for the current FetchPlan
 boolean getIgnoreCache()
          Accessor for whether to ignore the cache.
 java.util.Set getManagedObjects()
          Accessor for the objects currently managed by this PM in the current transaction.
 java.util.Set getManagedObjects(java.lang.Class... classes)
          Accessor for the objects currently managed by this PM in the current transaction.
 java.util.Set getManagedObjects(java.util.EnumSet states)
          Accessor for the objects currently managed by this PM in the current transaction.
 java.util.Set getManagedObjects(java.util.EnumSet states, java.lang.Class... classes)
          Accessor for the objects currently managed by this PM in the current transaction.
 boolean getMultithreaded()
          Accessor for whether the Persistence Manager is multithreaded.
 java.lang.Object getObjectById(java.lang.Class cls, java.lang.Object key)
          Convenience method that exactly matches the behavior of calling pm.getObjectById (pm.newObjectIdInstance (cls, key), true).
 java.lang.Object getObjectById(java.lang.Object id)
          Accessor for an object given the object id.
 java.lang.Object getObjectById(java.lang.Object id, boolean validate)
          Accessor for an object given the object id.
 java.lang.Object getObjectId(java.lang.Object pc)
          Accessor for an object id given the object.
 java.lang.Class getObjectIdClass(java.lang.Class cls)
          Accessor for the class of the object id given the class of object.
 ObjectManager getObjectManager()
          Convenience accessor for the ObjectManager performing the actual persistence.
 java.lang.Object[] getObjectsById(boolean validate, java.lang.Object... oids)
          Accessor for the objects given the object ids.
 java.util.Collection getObjectsById(java.util.Collection oids)
          Accessor for the objects given the object ids, validating the objects.
 java.util.Collection getObjectsById(java.util.Collection oids, boolean validate)
          Accessor for the objects given the object ids.
 java.lang.Object[] getObjectsById(java.lang.Object... oids)
          Accessor for the objects given the object ids, validating the objects.
 java.lang.Object[] getObjectsById(java.lang.Object[] oids, boolean validate)
          Accessor for the objects given the object ids.
 javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory()
          Accessor for the PersistenceManager Factory.
 javax.jdo.datastore.Sequence getSequence(java.lang.String sequenceName)
          Method to retrieve a sequence by name.
 java.util.Date getServerDate()
          Accessor for the date on the datastore.
 java.lang.Object getTransactionalObjectId(java.lang.Object pc)
          Accessor for the object id of a transactional object given the object.
 java.lang.Object getUserObject()
          The application might manage PersistenceManager instances by using an associated object for bookkeeping purposes.
 java.lang.Object getUserObject(java.lang.Object key)
          Method to get a user object from the PersistenceManager.
protected  boolean hasPersistenceInformationForClass(java.lang.Class cls)
          Utility method to check if the specified class has reachable metadata/annotations.
 boolean isClosed()
          Accessor for whether this ObjectManager is closed.
 void makeNontransactional(java.lang.Object pc)
          Method to make nontransactional an object.
 void makeNontransactionalAll(java.util.Collection pcs)
          Method to make nontransactional a collection of objects.
 void makeNontransactionalAll(java.lang.Object... pcs)
          Method to make nontransactional an array of objects.
 java.lang.Object makePersistent(java.lang.Object obj)
          JDO method to persist an object.
 java.util.Collection makePersistentAll(java.util.Collection pcs)
          JDO method to make persistent a collection of objects.
 java.lang.Object[] makePersistentAll(java.lang.Object... pcs)
          JDO method to make persistent an array of objects.
 void makeTransactional(java.lang.Object pc)
          Method to make transactional an object.
 void makeTransactionalAll(java.util.Collection pcs)
          Method to make transactional a collection of objects.
 void makeTransactionalAll(java.lang.Object... pcs)
          Method to make transactional an array of objects.
 void makeTransient(java.lang.Object pc)
          Method to make transient an object.
 void makeTransient(java.lang.Object pc, boolean useFetchPlan)
          Method to make transient an object allowing fetching using the fetch plan.
 void makeTransientAll(boolean includeFetchPlan, java.lang.Object... pcs)
          Method to make transient an array of objects.
 void makeTransientAll(java.util.Collection pcs)
          Method to make transient a collection of objects.
 void makeTransientAll(java.util.Collection pcs, boolean useFetchPlan)
          Method to make transient a collection of objects.
 void makeTransientAll(java.lang.Object... pcs)
          Method to make transient an array of objects.
 void makeTransientAll(java.lang.Object[] pcs, boolean includeFetchPlan)
          Method to make transient an array of objects.
 java.lang.Object newInstance(java.lang.Class pc)
          Method to generate an instance of an interface, abstract class, or concrete PC class.
 javax.jdo.Query newNamedQuery(java.lang.Class cls, java.lang.String queryName)
          Construct a query instance with the candidate class and the query name.
 java.lang.Object newObjectIdInstance(java.lang.Class pcClass, java.lang.Object key)
          This method returns an object id instance corresponding to the pcClass and key arguments.
 javax.jdo.Query newQuery()
          Construct an empty query instance.
 javax.jdo.Query newQuery(java.lang.Class cls)
          Construct a query instance with the candidate class specified.
 javax.jdo.Query newQuery(java.lang.Class cls, java.util.Collection cln)
          Construct a query instance with the candidate class and candidate Collection specified.
 javax.jdo.Query newQuery(java.lang.Class cls, java.util.Collection cln, java.lang.String filter)
          Construct a query instance with the candidate class, the candidate Collection, and filter specified.
 javax.jdo.Query newQuery(java.lang.Class cls, java.lang.String filter)
          Construct a query instance with the candidate class and filter specified.
 javax.jdo.Query newQuery(javax.jdo.Extent cln)
          Construct a query instance with the candidate Extent specified; the candidate class is taken from the Extent.
 javax.jdo.Query newQuery(javax.jdo.Extent cln, java.lang.String filter)
          Construct a query instance with the candidate Extent and filter specified.
 javax.jdo.Query newQuery(java.lang.Object obj)
          Construct a query instance from another query.
 javax.jdo.Query newQuery(java.lang.String query)
          Construct a query instance using the specified Single-String query.
 javax.jdo.Query newQuery(java.lang.String language, java.lang.Object query)
          Construct a query instance using the specified language and the specified query.
 java.lang.Object putUserObject(java.lang.Object key, java.lang.Object value)
          Method to put a user object into the PersistenceManager.
 void refresh(java.lang.Object obj)
          Method to do a refresh of an object.
 void refreshAll()
          Method to do a refresh of all objects.
 void refreshAll(java.util.Collection pcs)
          Method to do a refresh of a collection of objects.
 void refreshAll(javax.jdo.JDOException exc)
          Method to do a refresh of objects that failed verification in the exception.
 void refreshAll(java.lang.Object... pcs)
          Method to do a refresh of an array of objects.
 void removeInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener listener)
          Method to remove a currently registered lifecycle listener, as per JDO 2.0 spec 12.15.
 java.lang.Object removeUserObject(java.lang.Object key)
          Method to remove a user object from the PersistenceManager.
 void retrieve(java.lang.Object pc)
          Method to retrieve the fields of an object.
 void retrieve(java.lang.Object pc, boolean fgOnly)
          Method to retrieve the fields of an object.
 void retrieveAll(boolean fgOnly, java.lang.Object... pcs)
          Retrieve field values of instances from the store.
 void retrieveAll(java.util.Collection pcs)
          Method to retrieve a collection of objects.
 void retrieveAll(java.util.Collection pcs, boolean fgOnly)
          Retrieve field values of instances from the store.
 void retrieveAll(java.lang.Object... pcs)
          Method to retrieve an array of objects.
 void retrieveAll(java.lang.Object[] pcs, boolean fgOnly)
          Retrieve field values of instances from the store.
 void setCopyOnAttach(boolean flag)
          Mutator for whether to copy objects on attach.
 void setDatastoreReadTimeoutMillis(java.lang.Integer timeout)
          Mutator for the timeout to use for datastore reads.
 void setDatastoreWriteTimeoutMillis(java.lang.Integer timeout)
          Mutator for the timeout to use for datastore writes.
 void setDetachAllOnCommit(boolean flag)
          Mutator for whether to detach all objects on commit of the transaction.
 void setIgnoreCache(boolean flag)
          Mutator for whether to ignore the cache.
 void setMultithreaded(boolean flag)
          Mutator for whether the Persistence Manager is multithreaded.
protected  void setTransaction(Transaction tx)
          Method to allow setting of the transaction by a superclass.
 void setUserObject(java.lang.Object userObject)
          The application might manage PersistenceManager instances by using an associated object for bookkeeping purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localisation utility for output messages from core.


LOCALISER_JDO

protected static final Localiser LOCALISER_JDO
Localisation utility for output messages from jdo.


LOGGER

public static final NucleusLogger LOGGER
Logger for JDO.


objectMgr

protected ObjectManager objectMgr
Backing ObjectManager for this PersistenceManager.


jdotx

protected javax.jdo.Transaction jdotx

pmf

protected JDOPersistenceManagerFactory pmf
Owning PersistenceManagerFactory.


fetchPlan

protected JDOFetchPlan fetchPlan
JDO Fetch Plan.

Constructor Detail

JDOPersistenceManager

public JDOPersistenceManager(JDOPersistenceManagerFactory apmf,
                             java.lang.String userName,
                             java.lang.String password)
Constructor.

Parameters:
apmf - Persistence Manager Factory
userName - Username for the datastore
password - Password for the datastore
Method Detail

getObjectManager

public ObjectManager getObjectManager()
Convenience accessor for the ObjectManager performing the actual persistence.

Returns:
The ObjectManager

getPersistenceManagerFactory

public javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory()
Accessor for the PersistenceManager Factory.

Specified by:
getPersistenceManagerFactory in interface javax.jdo.PersistenceManager
Returns:
The PersistenceManagerFactory

getDetachAllOnCommit

public boolean getDetachAllOnCommit()
Accessor for whether to detach all objects on commit of the transaction.

Specified by:
getDetachAllOnCommit in interface javax.jdo.PersistenceManager
Returns:
Whether to detach all on commit.

getCopyOnAttach

public boolean getCopyOnAttach()
Accessor for whether to copy objects on attaching.

Specified by:
getCopyOnAttach in interface javax.jdo.PersistenceManager
Returns:
Whether to copy objects on attaching.

getFetchPlan

public javax.jdo.FetchPlan getFetchPlan()
Acessor for the current FetchPlan

Specified by:
getFetchPlan in interface javax.jdo.PersistenceManager
Returns:
The FetchPlan

getIgnoreCache

public boolean getIgnoreCache()
Accessor for whether to ignore the cache.

Specified by:
getIgnoreCache in interface javax.jdo.PersistenceManager
Returns:
Whether to ignore the cache.

getMultithreaded

public boolean getMultithreaded()
Accessor for whether the Persistence Manager is multithreaded.

Specified by:
getMultithreaded in interface javax.jdo.PersistenceManager
Returns:
Whether to run multithreaded.

setDetachAllOnCommit

public void setDetachAllOnCommit(boolean flag)
Mutator for whether to detach all objects on commit of the transaction.

Specified by:
setDetachAllOnCommit in interface javax.jdo.PersistenceManager
Parameters:
flag - Whether to detach all on commit.

setCopyOnAttach

public void setCopyOnAttach(boolean flag)
Mutator for whether to copy objects on attach.

Specified by:
setCopyOnAttach in interface javax.jdo.PersistenceManager
Parameters:
flag - Whether to copy on attaching

setIgnoreCache

public void setIgnoreCache(boolean flag)
Mutator for whether to ignore the cache.

Specified by:
setIgnoreCache in interface javax.jdo.PersistenceManager
Parameters:
flag - Whether to ignore the cache.

setMultithreaded

public void setMultithreaded(boolean flag)
Mutator for whether the Persistence Manager is multithreaded.

Specified by:
setMultithreaded in interface javax.jdo.PersistenceManager
Parameters:
flag - Whether to run multithreaded.

getServerDate

public java.util.Date getServerDate()
Accessor for the date on the datastore.

Specified by:
getServerDate in interface javax.jdo.PersistenceManager
Returns:
Date on the datastore

close

public void close()
Method to close the Persistence Manager.

Specified by:
close in interface javax.jdo.PersistenceManager

isClosed

public boolean isClosed()
Accessor for whether this ObjectManager is closed.

Specified by:
isClosed in interface javax.jdo.PersistenceManager
Returns:
Whether this manager is closed.

currentTransaction

public javax.jdo.Transaction currentTransaction()
Accessor for the current transaction.

Specified by:
currentTransaction in interface javax.jdo.PersistenceManager
Returns:
The transaction

setTransaction

protected void setTransaction(Transaction tx)
Method to allow setting of the transaction by a superclass.

Parameters:
tx - The transaction

evict

public void evict(java.lang.Object obj)
Method to evict an object from L1 cache.

Specified by:
evict in interface javax.jdo.PersistenceManager
Parameters:
obj - The object
Throws:
javax.jdo.JDOUserException - thrown if some instances could not be evicted

evictAll

public void evictAll(boolean subclasses,
                     java.lang.Class cls)
Method to evict all objects of the specified type (and optionaly its subclasses).

Specified by:
evictAll in interface javax.jdo.PersistenceManager
Parameters:
cls - Type of persistable object
subclasses - Whether to include subclasses

evictAll

public void evictAll(java.lang.Object... pcs)
Method to evict an array of objects from L1 cache.

Specified by:
evictAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects

evictAll

public void evictAll(java.util.Collection pcs)
Method to evict a collection of objects from L1 cache.

Specified by:
evictAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects
Throws:
javax.jdo.JDOUserException - thrown if some instances could not be evicted

evictAll

public void evictAll()
Method to evict all current objects from L1 cache.

Specified by:
evictAll in interface javax.jdo.PersistenceManager

refresh

public void refresh(java.lang.Object obj)
Method to do a refresh of an object.

Specified by:
refresh in interface javax.jdo.PersistenceManager
Parameters:
obj - The Object
Throws:
javax.jdo.JDOUserException - thrown if the object could not be refreshed

refreshAll

public void refreshAll(java.lang.Object... pcs)
Method to do a refresh of an array of objects.

Specified by:
refreshAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The Objects

refreshAll

public void refreshAll(java.util.Collection pcs)
Method to do a refresh of a collection of objects.

Specified by:
refreshAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The Objects
Throws:
javax.jdo.JDOUserException - thrown if instances could not be refreshed.

refreshAll

public void refreshAll()
Method to do a refresh of all objects.

Specified by:
refreshAll in interface javax.jdo.PersistenceManager
Throws:
javax.jdo.JDOUserException - thrown if instances could not be refreshed.

refreshAll

public void refreshAll(javax.jdo.JDOException exc)
Method to do a refresh of objects that failed verification in the exception.

Specified by:
refreshAll in interface javax.jdo.PersistenceManager
Parameters:
exc - The JDO exception containing the objects that failed

retrieve

public void retrieve(java.lang.Object pc,
                     boolean fgOnly)
Method to retrieve the fields of an object.

Specified by:
retrieve in interface javax.jdo.PersistenceManager
Parameters:
pc - The object
fgOnly - Whether to retrieve the current fetch group fields only

retrieve

public void retrieve(java.lang.Object pc)
Method to retrieve the fields of an object.

Specified by:
retrieve in interface javax.jdo.PersistenceManager
Parameters:
pc - The object

retrieveAll

public void retrieveAll(java.lang.Object... pcs)
Method to retrieve an array of objects.

Specified by:
retrieveAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects

retrieveAll

public void retrieveAll(java.lang.Object[] pcs,
                        boolean fgOnly)
Retrieve field values of instances from the store. This tells the PersistenceManager that the application intends to use the instances, and their field values should be retrieved. The fields in the current fetch group must be retrieved, and the implementation might retrieve more fields than the current fetch group.

The PersistenceManager might use policy information about the class to retrieve associated instances.

Specified by:
retrieveAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the instances
fgOnly - whether to retrieve only the current fetch group fields

retrieveAll

public void retrieveAll(boolean fgOnly,
                        java.lang.Object... pcs)
Retrieve field values of instances from the store. As the equivalent method but arguments reversed for JDK1.5+.

Specified by:
retrieveAll in interface javax.jdo.PersistenceManager
Parameters:
fgOnly - whether to retrieve only the current fetch group fields
pcs - the instances

retrieveAll

public void retrieveAll(java.util.Collection pcs,
                        boolean fgOnly)
Retrieve field values of instances from the store. This tells the PersistenceManager that the application intends to use the instances, and their field values should be retrieved. The fields in the current fetch group must be retrieved, and the implementation might retrieve more fields than the current fetch group.

The PersistenceManager might use policy information about the class to retrieve associated instances.

Specified by:
retrieveAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the instances
fgOnly - whether to retrieve only the current fetch-group fields

retrieveAll

public void retrieveAll(java.util.Collection pcs)
Method to retrieve a collection of objects. Throws a JDOUserException if instances could not be retrieved.

Specified by:
retrieveAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects

makePersistent

public java.lang.Object makePersistent(java.lang.Object obj)
JDO method to persist an object. Will also attach a previously detached object.

Specified by:
makePersistent in interface javax.jdo.PersistenceManager
Parameters:
obj - The object
Returns:
The persisted object

makePersistentAll

public java.lang.Object[] makePersistentAll(java.lang.Object... pcs)
JDO method to make persistent an array of objects.

Specified by:
makePersistentAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects to persist

makePersistentAll

public java.util.Collection makePersistentAll(java.util.Collection pcs)
JDO method to make persistent a collection of objects. Throws a JDOUserException if objects could not be made persistent.

Specified by:
makePersistentAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects to persist

deletePersistent

public void deletePersistent(java.lang.Object obj)
JDO method to delete an object from the datastore.

Specified by:
deletePersistent in interface javax.jdo.PersistenceManager
Parameters:
obj - The object

deletePersistentAll

public void deletePersistentAll(java.lang.Object... pcs)
JDO method to delete an array of objects from the datastore.

Specified by:
deletePersistentAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects
Throws:
javax.jdo.JDOUserException - Thrown if one (or more) object cannot be deleted

deletePersistentAll

public void deletePersistentAll(java.util.Collection pcs)
JDO method to delete a collection of objects from the datastore. Throws a JDOUserException if objects could not be deleted.

Specified by:
deletePersistentAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects
Throws:
javax.jdo.JDOUserException - Thrown if one (or more) object cannot be deleted

makeTransient

public void makeTransient(java.lang.Object pc,
                          boolean useFetchPlan)
Method to make transient an object allowing fetching using the fetch plan.

Specified by:
makeTransient in interface javax.jdo.PersistenceManager
Parameters:
pc - The object
useFetchPlan - Whether to make transient all objects in the fetch plan

makeTransient

public void makeTransient(java.lang.Object pc)
Method to make transient an object. This doesn't use the fetch plan and just makes the specified object transient.

Specified by:
makeTransient in interface javax.jdo.PersistenceManager
Parameters:
pc - The object

makeTransientAll

public void makeTransientAll(java.lang.Object... pcs)
Method to make transient an array of objects.

Specified by:
makeTransientAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects

makeTransientAll

public void makeTransientAll(java.lang.Object[] pcs,
                             boolean includeFetchPlan)
Method to make transient an array of objects.

Specified by:
makeTransientAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects
includeFetchPlan - Whether to make transient all objects in the fetch plan

makeTransientAll

public void makeTransientAll(boolean includeFetchPlan,
                             java.lang.Object... pcs)
Method to make transient an array of objects.

Specified by:
makeTransientAll in interface javax.jdo.PersistenceManager
Parameters:
includeFetchPlan - Whether to make transient all objects in the fetch plan
pcs - The objects

makeTransientAll

public void makeTransientAll(java.util.Collection pcs,
                             boolean useFetchPlan)
Method to make transient a collection of objects.

Specified by:
makeTransientAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects
useFetchPlan - Whether to use the fetch plan when making transient
Throws:
javax.jdo.JDOUserException - thrown if objects could not be made transient.

makeTransientAll

public void makeTransientAll(java.util.Collection pcs)
Method to make transient a collection of objects.

Specified by:
makeTransientAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects
Throws:
javax.jdo.JDOUserException - thrown if objects could not be made transient.

makeTransactional

public void makeTransactional(java.lang.Object pc)
Method to make transactional an object.

Specified by:
makeTransactional in interface javax.jdo.PersistenceManager
Parameters:
pc - The object

makeTransactionalAll

public void makeTransactionalAll(java.lang.Object... pcs)
Method to make transactional an array of objects.

Specified by:
makeTransactionalAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects

makeTransactionalAll

public void makeTransactionalAll(java.util.Collection pcs)
Method to make transactional a collection of objects.

Specified by:
makeTransactionalAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects
Throws:
javax.jdo.JDOUserException - thrown if objects could not be made transactional

makeNontransactional

public void makeNontransactional(java.lang.Object pc)
Method to make nontransactional an object.

Specified by:
makeNontransactional in interface javax.jdo.PersistenceManager
Parameters:
pc - The object

makeNontransactionalAll

public void makeNontransactionalAll(java.lang.Object... pcs)
Method to make nontransactional an array of objects.

Specified by:
makeNontransactionalAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects.

makeNontransactionalAll

public void makeNontransactionalAll(java.util.Collection pcs)
Method to make nontransactional a collection of objects.

Specified by:
makeNontransactionalAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - The objects.
Throws:
javax.jdo.JDOUserException - thrown if objects could not be made nontransactional

detachCopy

public java.lang.Object detachCopy(java.lang.Object pc)
JDO method to detach a persistent object. If the object is of class that is not detachable a transient copy will be returned. If the object is not persistent it will be persisted first before detaching a copy.

Specified by:
detachCopy in interface javax.jdo.PersistenceManager
Parameters:
pc - The object
Returns:
The detached object

detachCopyAll

public java.lang.Object[] detachCopyAll(java.lang.Object... pcs)
Detach the specified objects from the PersistenceManager. The objects returned can be manipulated and re-attached with makePersistentAll(Object[]). The detached instances will be unmanaged copies of the specified parameters, and are suitable for serialization and manipulation outside of a JDO environment. When detaching instances, only fields in the current FetchPlan will be traversed. Thus, to detach a graph of objects, relations to other persistent instances must either be in the default-fetch-group, or in the current custom FetchPlan.

Specified by:
detachCopyAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the instances to detach
Returns:
the detached instances

detachCopyAll

public java.util.Collection detachCopyAll(java.util.Collection pcs)
Detach the specified objects from the PersistenceManager.

Specified by:
detachCopyAll in interface javax.jdo.PersistenceManager
Parameters:
pcs - the instances to detach
Returns:
the detached instances
See Also:
detachCopyAll(Object[])

newQuery

public javax.jdo.Query newQuery()
Construct an empty query instance.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Returns:
The query

newQuery

public javax.jdo.Query newQuery(java.lang.Object obj)
Construct a query instance from another query. The parameter might be a serialized/restored Query instance from the same JDO vendor but a different execution environment, or the parameter might be currently bound to a PersistenceManager from the same JDO vendor. Any of the elements Class, Filter, IgnoreCache flag, Import declarations, Variable declarations, Parameter declarations, and Ordering from the parameter Query are copied to the new Query instance, but a candidate Collection or Extent element is discarded.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
obj - The object to use in the query
Returns:
The query

newQuery

public javax.jdo.Query newQuery(java.lang.String query)
Construct a query instance using the specified Single-String query.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
query - The single-string query
Returns:
The Query

newQuery

public javax.jdo.Query newQuery(java.lang.String language,
                                java.lang.Object query)
Construct a query instance using the specified language and the specified query. The query instance will be of a class defined by the query language.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
language - The language parameter for the JDO Query language. This is by default "javax.jdo.query.JDOQL", but in JDO 2.0 can also be "javax.jdo.query.SQL", or vendor provided languages.
query - The query object
Returns:
The query

newQuery

public javax.jdo.Query newQuery(java.lang.Class cls)
Construct a query instance with the candidate class specified.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cls - The class to query
Returns:
The query

newQuery

public javax.jdo.Query newQuery(javax.jdo.Extent cln)
Construct a query instance with the candidate Extent specified; the candidate class is taken from the Extent.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cln - The extent to query
Returns:
The query

newQuery

public javax.jdo.Query newQuery(java.lang.Class cls,
                                java.util.Collection cln)
Construct a query instance with the candidate class and candidate Collection specified.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cls - The class to query
cln - The collection
Returns:
The query

newQuery

public javax.jdo.Query newQuery(java.lang.Class cls,
                                java.lang.String filter)
Construct a query instance with the candidate class and filter specified.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cls - The class to query
filter - A filter to apply
Returns:
The query

newQuery

public javax.jdo.Query newQuery(java.lang.Class cls,
                                java.util.Collection cln,
                                java.lang.String filter)
Construct a query instance with the candidate class, the candidate Collection, and filter specified.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cls - The class to query
cln - A collection
filter - A filter to apply
Returns:
The query

newQuery

public javax.jdo.Query newQuery(javax.jdo.Extent cln,
                                java.lang.String filter)
Construct a query instance with the candidate Extent and filter specified. The candidate class is taken from the Extent.

Specified by:
newQuery in interface javax.jdo.PersistenceManager
Parameters:
cln - The extent to query
filter - A filter to apply
Returns:
The query

newNamedQuery

public javax.jdo.Query newNamedQuery(java.lang.Class cls,
                                     java.lang.String queryName)
Construct a query instance with the candidate class and the query name.

Specified by:
newNamedQuery in interface javax.jdo.PersistenceManager
Parameters:
cls - The class to query
queryName - Name of the query.
Returns:
The query

getExtent

public javax.jdo.Extent getExtent(java.lang.Class pcClass,
                                  boolean subclasses)
Extents are collections of datastore objects managed by the datastore, not by explicit user operations on collections. Extent capability is a boolean property of classes that are persistence capable. If an instance of a class that has a managed extent is made persistent via reachability, the instance is put into the extent implicitly.

Specified by:
getExtent in interface javax.jdo.PersistenceManager
Parameters:
pcClass - The class to query
subclasses - Whether to include subclasses in the query.
Returns:
returns an Extent that contains all of the instances in the parameter class, and if the subclasses flag is true, all of the instances of the parameter class and its subclasses.

getExtent

public javax.jdo.Extent getExtent(java.lang.Class pcClass)
Extents are collections of datastore objects managed by the datastore, not by explicit user operations on collections. Extent capability is a boolean property of classes that are persistence capable. If an instance of a class that has a managed extent is made persistent via reachability, the instance is put into the extent implicitly.

Specified by:
getExtent in interface javax.jdo.PersistenceManager
Parameters:
pcClass - The class to query
Returns:
returns an Extent that contains all of the instances in the parameter class, and all of the instances of the parameter class and its subclasses.

newInstance

public java.lang.Object newInstance(java.lang.Class pc)
Method to generate an instance of an interface, abstract class, or concrete PC class.

Specified by:
newInstance in interface javax.jdo.PersistenceManager
Parameters:
pc - The class of the interface or abstract class, or concrete class defined in MetaData
Returns:
The instance of this type

newObjectIdInstance

public java.lang.Object newObjectIdInstance(java.lang.Class pcClass,
                                            java.lang.Object key)
This method returns an object id instance corresponding to the pcClass and key arguments. It has 2 modes of operation. Where SingleFieldIdentity is being used the key is the value of the key field. For all other cases the key is the String form of the object id instance.

Specified by:
newObjectIdInstance in interface javax.jdo.PersistenceManager
Parameters:
pcClass - Class of the PersistenceCapable to create the OID for.
key - Value of the key for SingleFieldIdentity, or toString() for other cases
Returns:
The new object-id instance

getManagedObjects

public java.util.Set getManagedObjects()
Accessor for the objects currently managed by this PM in the current transaction.

Specified by:
getManagedObjects in interface javax.jdo.PersistenceManager
Returns:
The managed objects

getManagedObjects

public java.util.Set getManagedObjects(java.lang.Class... classes)
Accessor for the objects currently managed by this PM in the current transaction.

Specified by:
getManagedObjects in interface javax.jdo.PersistenceManager
Parameters:
classes - Classes that we want objects for
Returns:
The managed objects

getManagedObjects

public java.util.Set getManagedObjects(java.util.EnumSet states)
Accessor for the objects currently managed by this PM in the current transaction.

Specified by:
getManagedObjects in interface javax.jdo.PersistenceManager
Parameters:
states - States that we want objects for
Returns:
The managed objects

getManagedObjects

public java.util.Set getManagedObjects(java.util.EnumSet states,
                                       java.lang.Class... classes)
Accessor for the objects currently managed by this PM in the current transaction.

Specified by:
getManagedObjects in interface javax.jdo.PersistenceManager
Parameters:
states - States that we want objects for
classes - Classes that we want objects for
Returns:
The managed objects

getObjectById

public java.lang.Object getObjectById(java.lang.Object id)
Accessor for an object given the object id.

Specified by:
getObjectById in interface javax.jdo.PersistenceManager
Parameters:
id - Id of the object.
Returns:
The Object

getObjectById

public java.lang.Object getObjectById(java.lang.Object id,
                                      boolean validate)
Accessor for an object given the object id.

Specified by:
getObjectById in interface javax.jdo.PersistenceManager
Parameters:
id - Id of the object.
validate - Whether to validate the object state
Returns:
The Object

getObjectById

public java.lang.Object getObjectById(java.lang.Class cls,
                                      java.lang.Object key)
Convenience method that exactly matches the behavior of calling pm.getObjectById (pm.newObjectIdInstance (cls, key), true).

Specified by:
getObjectById in interface javax.jdo.PersistenceManager
Parameters:
cls - Class of the PersistenceCapable
key - Value of the key field for SingleFieldIdentity, or the string value of the key otherwise
Returns:
The object for this id.

getObjectsById

public java.lang.Object[] getObjectsById(boolean validate,
                                         java.lang.Object... oids)
Accessor for the objects given the object ids.

Specified by:
getObjectsById in interface javax.jdo.PersistenceManager
Parameters:
validate - Whether to validate the object state
oids - Ids of the objects.
Returns:
The Objects with these ids (in the same order)

getObjectsById

public java.lang.Object[] getObjectsById(java.lang.Object[] oids,
                                         boolean validate)
Accessor for the objects given the object ids.

Specified by:
getObjectsById in interface javax.jdo.PersistenceManager
Parameters:
oids - Ids of the objects.
validate - Whether to validate the object state
Returns:
The Objects with these ids (in the same order)

getObjectsById

public java.lang.Object[] getObjectsById(java.lang.Object... oids)
Accessor for the objects given the object ids, validating the objects.

Specified by:
getObjectsById in interface javax.jdo.PersistenceManager
Parameters:
oids - Ids of the objects.
Returns:
The Objects with these ids (in the same order)

getObjectsById

public java.util.Collection getObjectsById(java.util.Collection oids)
Accessor for the objects given the object ids, validating the objects.

Specified by:
getObjectsById in interface javax.jdo.PersistenceManager
Parameters:
oids - Ids of the objects.
Returns:
The Objects with these ids (in the same order)

getObjectsById

public java.util.Collection getObjectsById(java.util.Collection oids,
                                           boolean validate)
Accessor for the objects given the object ids.

Specified by:
getObjectsById in interface javax.jdo.PersistenceManager
Parameters:
oids - Ids of the objects.
validate - Whether to validate the object state
Returns:
The Objects with these ids (in the same order)

getObjectId

public java.lang.Object getObjectId(java.lang.Object pc)
Accessor for an object id given the object.

Specified by:
getObjectId in interface javax.jdo.PersistenceManager
Parameters:
pc - The object
Returns:
The Object id

getTransactionalObjectId

public java.lang.Object getTransactionalObjectId(java.lang.Object pc)
Accessor for the object id of a transactional object given the object.

Specified by:
getTransactionalObjectId in interface javax.jdo.PersistenceManager
Parameters:
pc - The object
Returns:
The Object id

getObjectIdClass

public java.lang.Class getObjectIdClass(java.lang.Class cls)
Accessor for the class of the object id given the class of object.

Specified by:
getObjectIdClass in interface javax.jdo.PersistenceManager
Parameters:
cls - The class name of the object
Returns:
The class name of the object id

putUserObject

public java.lang.Object putUserObject(java.lang.Object key,
                                      java.lang.Object value)
Method to put a user object into the PersistenceManager. This is so that multiple users can each have a user object for example. The parameter is not inspected or used in any way by the JDO implementation.

Specified by:
putUserObject in interface javax.jdo.PersistenceManager
Parameters:
key - The key to store the user object under
value - The object to store
Returns:
The previous value for this key

getUserObject

public java.lang.Object getUserObject(java.lang.Object key)
Method to get a user object from the PersistenceManager. This is for user objects which are stored under a key. The parameter is not inspected or used in any way by the JDO implementation.

Specified by:
getUserObject in interface javax.jdo.PersistenceManager
Parameters:
key - The key to store the user object under
Returns:
The user object for that key

removeUserObject

public java.lang.Object removeUserObject(java.lang.Object key)
Method to remove a user object from the PersistenceManager. This is for user objects which are stored under a key. The parameter is not inspected or used in any way by the JDO implementation.

Specified by:
removeUserObject in interface javax.jdo.PersistenceManager
Parameters:
key - The key whose uder object is to be removed.
Returns:
The user object that was removed

setUserObject

public void setUserObject(java.lang.Object userObject)
The application might manage PersistenceManager instances by using an associated object for bookkeeping purposes. These methods allow the user to manage the associated object. The parameter is not inspected or used in any way by the JDO implementation.

Specified by:
setUserObject in interface javax.jdo.PersistenceManager
Parameters:
userObject - The object

getUserObject

public java.lang.Object getUserObject()
The application might manage PersistenceManager instances by using an associated object for bookkeeping purposes. These methods allow the user to manage the associated object. The parameter is not inspected or used in any way by the JDO implementation.

Specified by:
getUserObject in interface javax.jdo.PersistenceManager
Returns:
The user object

flush

public void flush()
This method flushes all dirty, new, and deleted instances to the datastore. It has no effect if a transaction is not active. If a datastore transaction is active, this method synchronizes the cache with the datastore and reports any exceptions. If an optimistic transaction is active, this method obtains a datastore connection and synchronizes the cache with the datastore using this connection. The connection obtained by this method is held until the end of the transaction.

Specified by:
flush in interface javax.jdo.PersistenceManager

checkConsistency

public void checkConsistency()
This method validates the cache with the datastore. It has no effect if a transaction is not active. If a datastore transaction is active, this method verifies the consistency of instances in the cache against the datastore. An implementation might flush instances as if flush() were called, but it is not required to do so. If an optimistic transaction is active, this method obtains a datastore connection and verifies the consistency of the instances in the cache against the datastore. If any inconsistencies are detected, a JDOOptimisticVerificationException is thrown. This exception contains a nested JDOOptimisticVerificationException for each object that failed the consistency check. No datastore resources acquired during the execution of this method are held beyond the scope of this method.

Specified by:
checkConsistency in interface javax.jdo.PersistenceManager

getSequence

public javax.jdo.datastore.Sequence getSequence(java.lang.String sequenceName)
Method to retrieve a sequence by name. As per JDO2 spec section 12.14. If the named sequence is not known, throws a JDOUserException.

Specified by:
getSequence in interface javax.jdo.PersistenceManager
Parameters:
sequenceName - Fully qualified name of the sequence
Returns:
The sequence

addInstanceLifecycleListener

public void addInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener listener,
                                         java.lang.Class... classes)
Method to register a lifecycle listener as per JDO 2.0 spec 12.15.

Specified by:
addInstanceLifecycleListener in interface javax.jdo.PersistenceManager
Parameters:
listener - The instance lifecycle listener to sends events to
classes - The classes that it is interested in

removeInstanceLifecycleListener

public void removeInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener listener)
Method to remove a currently registered lifecycle listener, as per JDO 2.0 spec 12.15.

Specified by:
removeInstanceLifecycleListener in interface javax.jdo.PersistenceManager
Parameters:
listener - The instance lifecycle listener to remove.

assertIsOpen

protected void assertIsOpen()
Method to assert if this Persistence Manager is open.

Throws:
javax.jdo.JDOFatalUserException - if the PM is closed.

assertActiveTransaction

protected void assertActiveTransaction()
Method to assert if the current transaction is active. Throws a TransactionNotActiveException if not active.


assertWritable

protected void assertWritable()
Method to assert if the current transaction is active or non transactional writes are allowed.

Throws:
a - TransactionNotWritableException if not active and non transactional writes are disabled

assertReadable

protected void assertReadable(java.lang.String operation)
Method to assert if no active transaction and nontransactionalRead is not set.

Throws:
javax.jdo.JDOUserException - if the tx is not active and no non-transactional read is available

hasPersistenceInformationForClass

protected boolean hasPersistenceInformationForClass(java.lang.Class cls)
Utility method to check if the specified class has reachable metadata/annotations.

Parameters:
cls - The class to check
Returns:
Whether the class has reachable metadata/annotations.

getDataStoreConnection

public javax.jdo.datastore.JDOConnection getDataStoreConnection()
Accessor for a connection on the datastore. See JDO 2.0 spec section 12.16

Specified by:
getDataStoreConnection in interface javax.jdo.PersistenceManager
Returns:
The JDO connection to the datastore
See Also:
PersistenceManager.getDataStoreConnection()

getFetchGroup

public javax.jdo.FetchGroup getFetchGroup(java.lang.Class cls,
                                          java.lang.String name)
Method to return a fetch group for the specified class, with the specified name.

Specified by:
getFetchGroup in interface javax.jdo.PersistenceManager
Parameters:
cls - The class
name - The name of the fetch group
Returns:
FetchGroup

setDatastoreReadTimeoutMillis

public void setDatastoreReadTimeoutMillis(java.lang.Integer timeout)
Mutator for the timeout to use for datastore reads.

Specified by:
setDatastoreReadTimeoutMillis in interface javax.jdo.PersistenceManager
Parameters:
timeout - Datastore read timeout interval (millisecs)

getDatastoreReadTimeoutMillis

public java.lang.Integer getDatastoreReadTimeoutMillis()
Accessor for the datastore read timeout (milliseconds).

Specified by:
getDatastoreReadTimeoutMillis in interface javax.jdo.PersistenceManager
Returns:
datastore read timeout

setDatastoreWriteTimeoutMillis

public void setDatastoreWriteTimeoutMillis(java.lang.Integer timeout)
Mutator for the timeout to use for datastore writes.

Specified by:
setDatastoreWriteTimeoutMillis in interface javax.jdo.PersistenceManager
Parameters:
timeout - Datastore write timeout interval (millisecs)

getDatastoreWriteTimeoutMillis

public java.lang.Integer getDatastoreWriteTimeoutMillis()
Accessor for the datastore write timeout (milliseconds).

Specified by:
getDatastoreWriteTimeoutMillis in interface javax.jdo.PersistenceManager
Returns:
datastore write timeout


Copyright © 2010. All Rights Reserved.