Package org.datanucleus.api.jdo
Class JDOPersistenceManager
java.lang.Object
org.datanucleus.api.jdo.JDOPersistenceManager
- All Implemented Interfaces:
AutoCloseable,javax.jdo.PersistenceManager
Provide the basics of a JDO PersistenceManager using an underlying ExecutionContext to perform the actual persistence.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprotected org.datanucleus.ExecutionContextBacking ExecutionContext for this PersistenceManager.protected JDOFetchPlanJDO Fetch Plan.private Set<JDOFetchGroup> JDO Fetch Groups.protected javax.jdo.Transactionstatic final org.datanucleus.util.NucleusLoggerLogger for JDO.protected JDOPersistenceManagerFactoryOwning PersistenceManagerFactory.private ObjectUser object attached to the PM.Map of user objects attached to this PM. -
Constructor Summary
ConstructorsConstructorDescriptionJDOPersistenceManager(JDOPersistenceManagerFactory pmf, String userName, String password) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener listener, Class... classes) Method to register a lifecycle listener as per JDO 2.0 spec 12.15.voidaddTransactionEventListener(org.datanucleus.transaction.TransactionEventListener listener) Convenience method to add a listener for transaction events (begin, commit, rollback).protected voidMethod to assert if the current transaction is active.protected voidMethod to assert if this Persistence Manager is open.protected voidassertReadable(String operation) Method to assert if no active transaction and nontransactionalRead is not set.protected voidMethod to assert if the current transaction is active or non transactional writes are allowed.voidThis method validates the cache with the datastore.voidclose()Method to close the Persistence Manager.javax.jdo.TransactionAccessor for the current transaction.voiddeletePersistent(Object obj) JDO method to delete an object from the datastore.voiddeletePersistentAll(Object... pcs) JDO method to delete an array of objects from the datastore.voidJDO method to delete a collection of objects from the datastore.<T> TdetachCopy(T pc) JDO method to detach a persistent object.<T> Collection<T> detachCopyAll(Collection<T> pcs) Detach the specified objects from thePersistenceManager.<T> T[]detachCopyAll(T... pcs) Detach the specified objects from thePersistenceManager.voidMethod to evict an object from L1 cache.voidevictAll()Method to evict all current objects from L1 cache.voidMethod to evict all objects of the specified type (and optionaly its subclasses).voidMethod to evict an array of objects from L1 cache.voidevictAll(Collection pcs) Method to evict a collection of objects from L1 cache.voidflush()This method flushes all dirty, new, and deleted instances to the datastore.booleanAccessor for whether to copy objects on attaching.javax.jdo.datastore.JDOConnectionAccessor for a connection on the datastore.Accessor for the datastore read timeout (milliseconds).Accessor for the datastore write timeout (milliseconds).booleanAccessor for whether to detach all objects on commit of the transaction.org.datanucleus.ExecutionContextConvenience accessor for the ExecutionContext performing the actual persistence.<T> javax.jdo.Extent<T> Extents are collections of datastore objects managed by the datastore, not by explicit user operations on collections.<T> javax.jdo.Extent<T> Extents are collections of datastore objects managed by the datastore, not by explicit user operations on collections.javax.jdo.FetchGroupgetFetchGroup(Class cls, String name) Method to return a fetch group for the specified class, with the specified name.javax.jdo.FetchPlanAcessor for the current FetchPlanbooleanAccessor for whether to ignore the cache.Accessor for the objects currently managed by this PM in the current transaction.getManagedObjects(Class... classes) Accessor for the objects currently managed by this PM in the current transaction.getManagedObjects(EnumSet states) Accessor for the objects currently managed by this PM in the current transaction.getManagedObjects(EnumSet states, Class... classes) Accessor for the objects currently managed by this PM in the current transaction.booleanAccessor for whether the Persistence Manager is multithreaded.<T> TgetObjectById(Class<T> cls, Object key) Method to look up the instance of the given type with the given key.getObjectById(Object id) Accessor for an object given the object id.getObjectById(Object id, boolean validate) Accessor for an object given the object id.<T> TgetObjectByUnique(Class<T> cls, String[] fieldNames, Object[] fieldValues) Method to look up the instance of the given type with the given key.getObjectId(Object pc) Accessor for an object id given the object.getObjectIdClass(Class cls) Accessor for the class of the object id given the class of object.Object[]getObjectsById(boolean validate, Object... oids) Accessor for the objects given the object ids.Object[]getObjectsById(Object... oids) Accessor for the objects given the object ids, validating the objects.getObjectsById(Collection oids) Accessor for the objects given the object ids, validating the objects.getObjectsById(Collection oids, boolean validate) Accessor for the objects given the object ids.Accessor for the PersistenceManager Factory.Get the properties and associated values currently in effect for the persistence manager.javax.jdo.datastore.SequencegetSequence(String sequenceName) Method to retrieve a sequence by name.Accessor for the date on the datastore.Get the names of the properties that are supported for use with the persistence manager.Accessor for the object id of a transactional object given the object.The application might manage PersistenceManager instances by using an associated object for bookkeeping purposes.getUserObject(Object key) Method to get a user object from the PersistenceManager.protected booleanUtility method to check if the specified class has reachable metadata/annotations.protected voidThe internal method called by the PMF to cleanup this PM.booleanisClosed()Accessor for whether this ExecutionContext is closed.private voidJDO Convenience method to wrap any DataNucleus exceptions for the deletePersistent process.private <T> TjdoDetachCopy(T obj, org.datanucleus.FetchPlanState state) JDO Convenience method to wrap any DataNucleus exceptions for the detachCopy process.private voidJDO Convenience method to wrap any DataNucleus exceptions for the evict process.private voidJDO Convenience method to wrap any DataNucleus exceptions for the makeNontransactional process.private <T> TjdoMakePersistent(T obj) JDO Convenience method to wrap any DataNucleus exceptions for the makePersistent process.private voidJDO Convenience method to wrap any DataNucleus exceptions for the makeTransactional process.private voidjdoMakeTransient(Object pc, org.datanucleus.FetchPlanState state) JDO Convenience method to wrap any DataNucleus exceptions for the makeTransient process.private voidjdoRefresh(Object obj) JDO Convenience method to wrap any DataNucleus exceptions for the refresh process.voidMethod to make nontransactional an object.voidmakeNontransactionalAll(Object... pcs) Method to make nontransactional an array of objects.voidMethod to make nontransactional a collection of objects.<T> TmakePersistent(T obj) JDO method to persist an object.<T> Collection<T> makePersistentAll(Collection<T> pcs) JDO method to make persistent a collection of objects.<T> T[]makePersistentAll(T... pcs) JDO method to make persistent an array of objects.voidMethod to make transactional an object.voidmakeTransactionalAll(Object... pcs) Method to make transactional an array of objects.voidMethod to make transactional a collection of objects.voidmakeTransient(Object pc) Method to make transient an object.voidmakeTransient(Object pc, boolean useFetchPlan) Method to make transient an object allowing fetching using the fetch plan.voidmakeTransientAll(boolean includeFetchPlan, Object... pcs) Method to make transient an array of objects.voidmakeTransientAll(Object... pcs) Method to make transient an array of objects.voidMethod to make transient a collection of objects.voidmakeTransientAll(Collection pcs, boolean useFetchPlan) Method to make transient a collection of objects.<T> TnewInstance(Class<T> pc) Method to generate an instance of an interface, abstract class, or concrete PC class.<T> javax.jdo.JDOQLTypedQuery<T> newJDOQLTypedQuery(Class<T> cls) Construct a JDOQLTypedQuery instance for the specified candidate.<T> javax.jdo.Query<T> newNamedQuery(Class<T> cls, String queryName) Construct a query instance with the candidate class and the query name.newObjectIdInstance(Class pcClass, Object key) This method returns an object id instance corresponding to the pcClass and key arguments.javax.jdo.QuerynewQuery()Construct an empty query instance.<T> javax.jdo.Query<T> Construct a query instance with the candidate class specified.<T> javax.jdo.Query<T> Construct a query instance with the candidate class and filter specified.<T> javax.jdo.Query<T> newQuery(Class<T> cls, Collection<T> cln) Construct a query instance with the candidate class and candidate Collection specified.<T> javax.jdo.Query<T> newQuery(Class<T> cls, Collection<T> cln, String filter) Construct a query instance with the candidate class, the candidate Collection, and filter specified.javax.jdo.QueryConstruct a query instance from another query.javax.jdo.QueryConstruct a query instance using the specified Single-String query.javax.jdo.QueryConstruct a query instance using the specified language and the specified query.<T> javax.jdo.Query<T> newQuery(javax.jdo.Extent<T> cln) Construct a query instance with the candidate Extent specified; the candidate class is taken from the Extent.<T> javax.jdo.Query<T> Construct a query instance with the candidate Extent and filter specified.putUserObject(Object key, Object value) Method to put a user object into the PersistenceManager.voidMethod to do a refresh of an object.voidMethod to do a refresh of all objects.voidrefreshAll(Object... pcs) Method to do a refresh of an array of objects.voidrefreshAll(Collection pcs) Method to do a refresh of a collection of objects.voidrefreshAll(javax.jdo.JDOException exc) Method to do a refresh of objects that failed verification in the exception.voidremoveInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener listener) Method to remove a currently registered lifecycle listener, as per JDO 2.0 spec 12.15.voidremoveTransactionEventListener(org.datanucleus.transaction.TransactionEventListener listener) Convenience method to remove the supplied listener from transaction event notification.removeUserObject(Object key) Method to remove a user object from the PersistenceManager.voidMethod to retrieve the fields of an object.voidMethod to retrieve the fields of an object.voidretrieveAll(boolean useFetchPlan, Object... pcs) Retrieve field values of instances from the store.voidretrieveAll(Object... pcs) Method to retrieve an array of objects.voidretrieveAll(Collection pcs) Method to retrieve a collection of objects.voidretrieveAll(Collection pcs, boolean useFetchPlan) Retrieve field values of instances from the store.voidsetCopyOnAttach(boolean flag) Mutator for whether to copy objects on attach.voidsetDatastoreReadTimeoutMillis(Integer timeout) Mutator for the timeout to use for datastore reads.voidsetDatastoreWriteTimeoutMillis(Integer timeout) Mutator for the timeout to use for datastore writes.voidsetDetachAllOnCommit(boolean flag) Mutator for whether to detach all objects on commit of the transaction.voidsetIgnoreCache(boolean flag) Mutator for whether to ignore the cache.voidsetMultithreaded(boolean flag) Mutator for whether the Persistence Manager is multithreaded.voidsetProperty(String propertyName, Object value) Set a persistence manager property.voidsetUserObject(Object userObject) The application might manage PersistenceManager instances by using an associated object for bookkeeping purposes.
-
Field Details
-
LOGGER
public static final org.datanucleus.util.NucleusLogger LOGGERLogger for JDO. -
closed
private boolean closed -
userObjectMap
Map of user objects attached to this PM. -
userObject
User object attached to the PM. -
ec
protected org.datanucleus.ExecutionContext ecBacking ExecutionContext for this PersistenceManager. -
jdotx
protected javax.jdo.Transaction jdotx -
pmf
Owning PersistenceManagerFactory. -
fetchPlan
JDO Fetch Plan. -
jdoFetchGroups
JDO Fetch Groups.
-
-
Constructor Details
-
JDOPersistenceManager
Constructor.- Parameters:
pmf- Persistence Manager FactoryuserName- Username for the datastorepassword- Password for the datastore
-
-
Method Details
-
close
public void close()Method to close the Persistence Manager.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacejavax.jdo.PersistenceManager
-
isClosed
public boolean isClosed()Accessor for whether this ExecutionContext is closed.- Specified by:
isClosedin interfacejavax.jdo.PersistenceManager- Returns:
- Whether this manager is closed.
-
internalClose
protected void internalClose()The internal method called by the PMF to cleanup this PM. Called from PMF.releasePersistenceManager(). -
getExecutionContext
public org.datanucleus.ExecutionContext getExecutionContext()Convenience accessor for the ExecutionContext performing the actual persistence.- Returns:
- The ExecutionContext
-
getPersistenceManagerFactory
Accessor for the PersistenceManager Factory.- Specified by:
getPersistenceManagerFactoryin interfacejavax.jdo.PersistenceManager- Returns:
- The PersistenceManagerFactory
-
getDetachAllOnCommit
public boolean getDetachAllOnCommit()Accessor for whether to detach all objects on commit of the transaction.- Specified by:
getDetachAllOnCommitin interfacejavax.jdo.PersistenceManager- Returns:
- Whether to detach all on commit.
-
getCopyOnAttach
public boolean getCopyOnAttach()Accessor for whether to copy objects on attaching.- Specified by:
getCopyOnAttachin interfacejavax.jdo.PersistenceManager- Returns:
- Whether to copy objects on attaching.
-
getFetchPlan
public javax.jdo.FetchPlan getFetchPlan()Acessor for the current FetchPlan- Specified by:
getFetchPlanin interfacejavax.jdo.PersistenceManager- Returns:
- The FetchPlan
-
getIgnoreCache
public boolean getIgnoreCache()Accessor for whether to ignore the cache.- Specified by:
getIgnoreCachein interfacejavax.jdo.PersistenceManager- Returns:
- Whether to ignore the cache.
-
getMultithreaded
public boolean getMultithreaded()Accessor for whether the Persistence Manager is multithreaded.- Specified by:
getMultithreadedin interfacejavax.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:
setDetachAllOnCommitin interfacejavax.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:
setCopyOnAttachin interfacejavax.jdo.PersistenceManager- Parameters:
flag- Whether to copy on attaching
-
setIgnoreCache
public void setIgnoreCache(boolean flag) Mutator for whether to ignore the cache.- Specified by:
setIgnoreCachein interfacejavax.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:
setMultithreadedin interfacejavax.jdo.PersistenceManager- Parameters:
flag- Whether to run multithreaded.
-
setDatastoreReadTimeoutMillis
Mutator for the timeout to use for datastore reads.- Specified by:
setDatastoreReadTimeoutMillisin interfacejavax.jdo.PersistenceManager- Parameters:
timeout- Datastore read timeout interval (millisecs)
-
getDatastoreReadTimeoutMillis
Accessor for the datastore read timeout (milliseconds).- Specified by:
getDatastoreReadTimeoutMillisin interfacejavax.jdo.PersistenceManager- Returns:
- datastore read timeout
-
setDatastoreWriteTimeoutMillis
Mutator for the timeout to use for datastore writes.- Specified by:
setDatastoreWriteTimeoutMillisin interfacejavax.jdo.PersistenceManager- Parameters:
timeout- Datastore write timeout interval (millisecs)
-
getDatastoreWriteTimeoutMillis
Accessor for the datastore write timeout (milliseconds).- Specified by:
getDatastoreWriteTimeoutMillisin interfacejavax.jdo.PersistenceManager- Returns:
- datastore write timeout
-
getServerDate
Accessor for the date on the datastore.- Specified by:
getServerDatein interfacejavax.jdo.PersistenceManager- Returns:
- Date on the datastore
-
currentTransaction
public javax.jdo.Transaction currentTransaction()Accessor for the current transaction.- Specified by:
currentTransactionin interfacejavax.jdo.PersistenceManager- Returns:
- The transaction
-
jdoEvict
JDO Convenience method to wrap any DataNucleus exceptions for the evict process.- Parameters:
obj- The object to evict- Throws:
javax.jdo.JDOUserException- thrown if some instances could not be evicted
-
evict
Method to evict an object from L1 cache.- Specified by:
evictin interfacejavax.jdo.PersistenceManager- Parameters:
obj- The object- Throws:
javax.jdo.JDOUserException- thrown if some instances could not be evicted
-
evictAll
Method to evict all objects of the specified type (and optionaly its subclasses).- Specified by:
evictAllin interfacejavax.jdo.PersistenceManager- Parameters:
subclasses- Whether to include subclassescls- Type of persistable object
-
evictAll
Method to evict an array of objects from L1 cache.- Specified by:
evictAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects
-
evictAll
Method to evict a collection of objects from L1 cache.- Specified by:
evictAllin interfacejavax.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:
evictAllin interfacejavax.jdo.PersistenceManager
-
jdoRefresh
JDO Convenience method to wrap any DataNucleus exceptions for the refresh process.- Parameters:
obj- The object to refresh- Throws:
javax.jdo.JDOUserException- thrown if the object could not be refreshed
-
refresh
Method to do a refresh of an object.- Specified by:
refreshin interfacejavax.jdo.PersistenceManager- Parameters:
obj- The Object- Throws:
javax.jdo.JDOUserException- thrown if the object could not be refreshed
-
refreshAll
Method to do a refresh of an array of objects.- Specified by:
refreshAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The Objects
-
refreshAll
Method to do a refresh of a collection of objects.- Specified by:
refreshAllin interfacejavax.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:
refreshAllin interfacejavax.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:
refreshAllin interfacejavax.jdo.PersistenceManager- Parameters:
exc- The JDO exception containing the objects that failed
-
retrieve
Method to retrieve the fields of an object.- Specified by:
retrievein interfacejavax.jdo.PersistenceManager- Parameters:
pc- The objectuseFetchPlan- whether to retrieve only the current fetch plan fields
-
retrieve
Method to retrieve the fields of an object.- Specified by:
retrievein interfacejavax.jdo.PersistenceManager- Parameters:
pc- The object
-
retrieveAll
Method to retrieve an array of objects.- Specified by:
retrieveAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects
-
retrieveAll
Retrieve field values of instances from the store.- Specified by:
retrieveAllin interfacejavax.jdo.PersistenceManager- Parameters:
useFetchPlan- whether to retrieve only the current fetch plan fieldspcs- the instances
-
retrieveAll
Retrieve field values of instances from the store. This tells thePersistenceManagerthat 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. ThePersistenceManagermight use policy information about the class to retrieve associated instances.- Specified by:
retrieveAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- the instancesuseFetchPlan- whether to retrieve only the current fetch plan fields
-
retrieveAll
Method to retrieve a collection of objects. Throws a JDOUserException if instances could not be retrieved.- Specified by:
retrieveAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects
-
jdoMakePersistent
private <T> T jdoMakePersistent(T obj) JDO Convenience method to wrap any DataNucleus exceptions for the makePersistent process.- Parameters:
obj- The object to persist- Returns:
- The persistent object
- Throws:
javax.jdo.JDOUserException- thrown if the object could not be persisted
-
makePersistent
public <T> T makePersistent(T obj) JDO method to persist an object. Will also attach a previously detached object.- Specified by:
makePersistentin interfacejavax.jdo.PersistenceManager- Parameters:
obj- The object- Returns:
- The persisted object
-
makePersistentAll
public <T> T[] makePersistentAll(T... pcs) JDO method to make persistent an array of objects.- Specified by:
makePersistentAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects to persist- Returns:
- The persistent objects
-
makePersistentAll
JDO method to make persistent a collection of objects. Throws a JDOUserException if objects could not be made persistent.- Specified by:
makePersistentAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects to persist- Returns:
- The persistent objects
-
jdoDeletePersistent
JDO Convenience method to wrap any DataNucleus exceptions for the deletePersistent process.- Parameters:
obj- The object to delete- Throws:
javax.jdo.JDOUserException- thrown if the object could not be deleted
-
deletePersistent
JDO method to delete an object from the datastore.- Specified by:
deletePersistentin interfacejavax.jdo.PersistenceManager- Parameters:
obj- The object
-
deletePersistentAll
JDO method to delete an array of objects from the datastore.- Specified by:
deletePersistentAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects- Throws:
javax.jdo.JDOUserException- Thrown if one (or more) object cannot be deleted
-
deletePersistentAll
JDO method to delete a collection of objects from the datastore. Throws a JDOUserException if objects could not be deleted.- Specified by:
deletePersistentAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects- Throws:
javax.jdo.JDOUserException- Thrown if one (or more) object cannot be deleted
-
jdoMakeTransient
JDO Convenience method to wrap any DataNucleus exceptions for the makeTransient process.- Parameters:
pc- The object to make transientstate- FetchPlanState- Throws:
javax.jdo.JDOUserException- thrown if the object could not be made transient
-
makeTransient
Method to make transient an object allowing fetching using the fetch plan.- Specified by:
makeTransientin interfacejavax.jdo.PersistenceManager- Parameters:
pc- The objectuseFetchPlan- Whether to make transient all objects in the fetch plan
-
makeTransient
Method to make transient an object. This doesn't use the fetch plan and just makes the specified object transient.- Specified by:
makeTransientin interfacejavax.jdo.PersistenceManager- Parameters:
pc- The object
-
makeTransientAll
Method to make transient an array of objects.- Specified by:
makeTransientAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects
-
makeTransientAll
Method to make transient an array of objects.- Specified by:
makeTransientAllin interfacejavax.jdo.PersistenceManager- Parameters:
includeFetchPlan- Whether to make transient all objects in the fetch planpcs- The objects
-
makeTransientAll
Method to make transient a collection of objects.- Specified by:
makeTransientAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objectsuseFetchPlan- Whether to use the fetch plan when making transient- Throws:
javax.jdo.JDOUserException- thrown if objects could not be made transient.
-
makeTransientAll
Method to make transient a collection of objects.- Specified by:
makeTransientAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects- Throws:
javax.jdo.JDOUserException- thrown if objects could not be made transient.
-
jdoMakeTransactional
JDO Convenience method to wrap any DataNucleus exceptions for the makeTransactional process.- Parameters:
pc- The object to make transactional- Throws:
javax.jdo.JDOUserException- thrown if the object could not be made transactional
-
makeTransactional
Method to make transactional an object.- Specified by:
makeTransactionalin interfacejavax.jdo.PersistenceManager- Parameters:
pc- The object
-
makeTransactionalAll
Method to make transactional an array of objects.- Specified by:
makeTransactionalAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects
-
makeTransactionalAll
Method to make transactional a collection of objects.- Specified by:
makeTransactionalAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects- Throws:
javax.jdo.JDOUserException- thrown if objects could not be made transactional
-
jdoMakeNontransactional
JDO Convenience method to wrap any DataNucleus exceptions for the makeNontransactional process.- Parameters:
obj- The object to make nontransactional- Throws:
javax.jdo.JDOUserException- thrown if the object could not be made nontransactional
-
makeNontransactional
Method to make nontransactional an object.- Specified by:
makeNontransactionalin interfacejavax.jdo.PersistenceManager- Parameters:
pc- The object
-
makeNontransactionalAll
Method to make nontransactional an array of objects.- Specified by:
makeNontransactionalAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects.
-
makeNontransactionalAll
Method to make nontransactional a collection of objects.- Specified by:
makeNontransactionalAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- The objects.- Throws:
javax.jdo.JDOUserException- thrown if objects could not be made nontransactional
-
jdoDetachCopy
private <T> T jdoDetachCopy(T obj, org.datanucleus.FetchPlanState state) JDO Convenience method to wrap any DataNucleus exceptions for the detachCopy process.- Parameters:
obj- The object to detach a copy ofstate- DetachState- Throws:
javax.jdo.JDOUserException- thrown if the object could not be detached
-
detachCopy
public <T> T detachCopy(T 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:
detachCopyin interfacejavax.jdo.PersistenceManager- Parameters:
pc- The object- Returns:
- The detached object
-
detachCopyAll
public <T> T[] detachCopyAll(T... pcs) Detach the specified objects from thePersistenceManager. The objects returned can be manipulated and re-attached withmakePersistentAll(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 currentFetchPlanwill be traversed. Thus, to detach a graph of objects, relations to other persistent instances must either be in thedefault-fetch-group, or in the current customFetchPlan.- Specified by:
detachCopyAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- the instances to detach- Returns:
- the detached instances
-
detachCopyAll
Detach the specified objects from thePersistenceManager.- Specified by:
detachCopyAllin interfacejavax.jdo.PersistenceManager- Parameters:
pcs- the instances to detach- Returns:
- the detached instances
- See Also:
-
newQuery
public javax.jdo.Query newQuery()Construct an empty query instance.- Specified by:
newQueryin interfacejavax.jdo.PersistenceManager- Returns:
- The query
-
newQuery
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:
newQueryin interfacejavax.jdo.PersistenceManager- Parameters:
obj- The object to use in the query- Returns:
- The query
-
newQuery
Construct a query instance using the specified Single-String query.- Specified by:
newQueryin interfacejavax.jdo.PersistenceManager- Parameters:
query- The single-string query- Returns:
- The Query
-
newQuery
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:
newQueryin interfacejavax.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
Construct a query instance with the candidate class specified.- Specified by:
newQueryin interfacejavax.jdo.PersistenceManager- Type Parameters:
T- Candidate type for the query- Parameters:
cls- The class to query- Returns:
- The query
-
newQuery
public <T> javax.jdo.Query<T> newQuery(javax.jdo.Extent<T> cln) Construct a query instance with the candidate Extent specified; the candidate class is taken from the Extent.- Specified by:
newQueryin interfacejavax.jdo.PersistenceManager- Type Parameters:
T- Candidate type for the query- Parameters:
cln- The extent to query- Returns:
- The query
-
newQuery
Construct a query instance with the candidate class and candidate Collection specified.- Specified by:
newQueryin interfacejavax.jdo.PersistenceManager- Type Parameters:
T- Candidate type for the query- Parameters:
cls- The class to querycln- The collection- Returns:
- The query
-
newQuery
Construct a query instance with the candidate class and filter specified.- Specified by:
newQueryin interfacejavax.jdo.PersistenceManager- Type Parameters:
T- Candidate type for the query- Parameters:
cls- The class to queryfilter- A filter to apply- Returns:
- The query
-
newQuery
Construct a query instance with the candidate class, the candidate Collection, and filter specified.- Specified by:
newQueryin interfacejavax.jdo.PersistenceManager- Type Parameters:
T- Candidate type for the query- Parameters:
cls- The class to querycln- A collectionfilter- A filter to apply- Returns:
- The query
-
newQuery
Construct a query instance with the candidate Extent and filter specified. The candidate class is taken from the Extent.- Specified by:
newQueryin interfacejavax.jdo.PersistenceManager- Type Parameters:
T- Candidate type for the query- Parameters:
cln- The extent to queryfilter- A filter to apply- Returns:
- The query
-
newJDOQLTypedQuery
Construct a JDOQLTypedQuery instance for the specified candidate.- Specified by:
newJDOQLTypedQueryin interfacejavax.jdo.PersistenceManager- Type Parameters:
T- Candidate type for the query- Parameters:
cls- Candidate class- Returns:
- The JDOQLTypedQuery
-
newNamedQuery
Construct a query instance with the candidate class and the query name.- Specified by:
newNamedQueryin interfacejavax.jdo.PersistenceManager- Type Parameters:
T- Candidate type for the query- Parameters:
cls- The class to queryqueryName- Name of the query.- Returns:
- The query
-
getExtent
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:
getExtentin interfacejavax.jdo.PersistenceManager- Type Parameters:
T- candidate type- Parameters:
pcClass- The class to querysubclasses- 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
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:
getExtentin interfacejavax.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
Method to generate an instance of an interface, abstract class, or concrete PC class.- Specified by:
newInstancein interfacejavax.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
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:
newObjectIdInstancein interfacejavax.jdo.PersistenceManager- Parameters:
pcClass- Class of the persistable to create the OID for.key- Value of the key for SingleFieldIdentity, or toString() for other cases- Returns:
- The new object-id instance
-
getManagedObjects
Accessor for the objects currently managed by this PM in the current transaction.- Specified by:
getManagedObjectsin interfacejavax.jdo.PersistenceManager- Returns:
- The managed objects
-
getManagedObjects
Accessor for the objects currently managed by this PM in the current transaction.- Specified by:
getManagedObjectsin interfacejavax.jdo.PersistenceManager- Parameters:
classes- Classes that we want objects for- Returns:
- The managed objects
-
getManagedObjects
Accessor for the objects currently managed by this PM in the current transaction.- Specified by:
getManagedObjectsin interfacejavax.jdo.PersistenceManager- Parameters:
states- States that we want objects for- Returns:
- The managed objects
-
getManagedObjects
Accessor for the objects currently managed by this PM in the current transaction.- Specified by:
getManagedObjectsin interfacejavax.jdo.PersistenceManager- Parameters:
states- States that we want objects forclasses- Classes that we want objects for- Returns:
- The managed objects
-
getObjectById
Accessor for an object given the object id.- Specified by:
getObjectByIdin interfacejavax.jdo.PersistenceManager- Parameters:
id- Id of the object.- Returns:
- The Object
-
getObjectById
Accessor for an object given the object id.- Specified by:
getObjectByIdin interfacejavax.jdo.PersistenceManager- Parameters:
id- Id of the object.validate- Whether to validate the object state- Returns:
- The Object
-
getObjectById
Method to look up the instance of the given type with the given key.- Specified by:
getObjectByIdin interfacejavax.jdo.PersistenceManager- Parameters:
cls- Class of the persistablekey- Value of the key field for SingleFieldIdentity, or the string value of the key otherwise- Returns:
- The object for this id.
-
getObjectsById
Accessor for the objects given the object ids.- Specified by:
getObjectsByIdin interfacejavax.jdo.PersistenceManager- Parameters:
validate- Whether to validate the object stateoids- Ids of the objects.- Returns:
- The Objects with these ids (in the same order)
-
getObjectsById
Accessor for the objects given the object ids, validating the objects.- Specified by:
getObjectsByIdin interfacejavax.jdo.PersistenceManager- Parameters:
oids- Ids of the objects.- Returns:
- The Objects with these ids (in the same order)
-
getObjectsById
Accessor for the objects given the object ids, validating the objects.- Specified by:
getObjectsByIdin interfacejavax.jdo.PersistenceManager- Parameters:
oids- Ids of the objects.- Returns:
- The Objects with these ids (in the same order)
-
getObjectsById
Accessor for the objects given the object ids.- Specified by:
getObjectsByIdin interfacejavax.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)
-
getObjectByUnique
Method to look up the instance of the given type with the given key.- Type Parameters:
T- Type of the object- Parameters:
cls- Class of the persistablefieldNames- Name(s) of the field(s) making up the unique keyfieldValues- Value(s) for the field(s) making up the unique key- Returns:
- The object meeting this selection.
-
getObjectId
Accessor for an object id given the object.- Specified by:
getObjectIdin interfacejavax.jdo.PersistenceManager- Parameters:
pc- The object- Returns:
- The Object id
-
getTransactionalObjectId
Accessor for the object id of a transactional object given the object.- Specified by:
getTransactionalObjectIdin interfacejavax.jdo.PersistenceManager- Parameters:
pc- The object- Returns:
- The Object id
-
getObjectIdClass
Accessor for the class of the object id given the class of object.- Specified by:
getObjectIdClassin interfacejavax.jdo.PersistenceManager- Parameters:
cls- The class name of the object- Returns:
- The class name of the object id
-
putUserObject
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:
putUserObjectin interfacejavax.jdo.PersistenceManager- Parameters:
key- The key to store the user object undervalue- The object to store- Returns:
- The previous value for this key
-
getUserObject
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:
getUserObjectin interfacejavax.jdo.PersistenceManager- Parameters:
key- The key to store the user object under- Returns:
- The user object for that key
-
removeUserObject
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:
removeUserObjectin interfacejavax.jdo.PersistenceManager- Parameters:
key- The key whose uder object is to be removed.- Returns:
- The user object that was removed
-
setUserObject
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:
setUserObjectin interfacejavax.jdo.PersistenceManager- Parameters:
userObject- The 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:
getUserObjectin interfacejavax.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:
flushin interfacejavax.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:
checkConsistencyin interfacejavax.jdo.PersistenceManager
-
getSequence
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:
getSequencein interfacejavax.jdo.PersistenceManager- Parameters:
sequenceName- Fully qualified name of the sequence- Returns:
- The sequence
-
addInstanceLifecycleListener
public void addInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener listener, Class... classes) Method to register a lifecycle listener as per JDO 2.0 spec 12.15.- Specified by:
addInstanceLifecycleListenerin interfacejavax.jdo.PersistenceManager- Parameters:
listener- The instance lifecycle listener to sends events toclasses- 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:
removeInstanceLifecycleListenerin interfacejavax.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
Method to assert if no active transaction and nontransactionalRead is not set. Throws JDOUserException if the tx is not active and no non-transactional read is available- Parameters:
operation- The operation
-
hasPersistenceInformationForClass
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:
getDataStoreConnectionin interfacejavax.jdo.PersistenceManager- Returns:
- The JDO connection to the datastore
- See Also:
-
getFetchGroup
Method to return a fetch group for the specified class, with the specified name.- Specified by:
getFetchGroupin interfacejavax.jdo.PersistenceManager- Parameters:
cls- The classname- The name of the fetch group- Returns:
- FetchGroup
-
setProperty
Set a persistence manager property. This can be a standard property or a vendor-extension property. If a vendor-extension property is not recognized, it is silently ignored.- Specified by:
setPropertyin interfacejavax.jdo.PersistenceManager- Parameters:
propertyName- name of propertyvalue- The value- Throws:
javax.jdo.JDOUserException- if the value is not supported for the property- Since:
- JDO3.1
-
getProperties
Get the properties and associated values currently in effect for the persistence manager. Changing entries in the map will not have affect the configuration of the persistence manager.- Specified by:
getPropertiesin interfacejavax.jdo.PersistenceManager- Returns:
- map of properties in effect
- Since:
- JDO3.1
-
getSupportedProperties
Get the names of the properties that are supported for use with the persistence manager. These can be standard JDO properties, or can be vendor-extension properties.- Specified by:
getSupportedPropertiesin interfacejavax.jdo.PersistenceManager- Returns:
- property names Names of the properties accepted
- Since:
- JDO3.1
-
addTransactionEventListener
public void addTransactionEventListener(org.datanucleus.transaction.TransactionEventListener listener) Convenience method to add a listener for transaction events (begin, commit, rollback).- Parameters:
listener- The listener.
-
removeTransactionEventListener
public void removeTransactionEventListener(org.datanucleus.transaction.TransactionEventListener listener) Convenience method to remove the supplied listener from transaction event notification.- Parameters:
listener- The listener
-