Package org.datanucleus.store
Interface StorePersistenceHandler
- All Known Implementing Classes:
AbstractPersistenceHandler
,FederatedPersistenceHandler
public interface StorePersistenceHandler
Interface defining persistence operations of a StoreManager.
This performs the low level communication with the actual datastore.
To be implemented by all new datastore support. Please use AbstractPersistenceHandler and extend it.
All PersistenceHandlers should have a single constructor with signature
public MyPersistenceHandler(StoreManager storeMgr) { }
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Enum for the type of a batched operation -
Method Summary
Modifier and TypeMethodDescriptiondefault void
Signal that the current batch of operations are ending for the specified ExecutionContext.default void
Signal that a batch of operations are starting for the specified ExecutionContext.void
close()
Method to close the persistence handler, and release any resources.void
Deletes a persistent object from the datastore.default void
deleteObjects
(DNStateManager... sms) Method to delete an array of objects from the datastore.void
fetchObject
(DNStateManager sm, int[] fieldNumbers) Fetches specified fields of a persistent object from the database.default void
fetchObjects
(int[] fieldNumbers, DNStateManager... sms) Fetches specified fields of several persistent objects (of the same type) from the database.findObject
(ExecutionContext ec, Object id) Method to find a persistable object with the specified id from the datastore, if the StoreManager supports this operation (optional).findObjectForUnique
(ExecutionContext ec, AbstractClassMetaData cmd, String[] memberNames, Object[] values) Method to find the object with the specified value(s) for the member(s) of the specified type.default Object[]
findObjects
(ExecutionContext ec, Object[] ids) Method to find an array of objects with the specified identities from the datastore.void
Inserts a persistent object into the database.default void
insertObjects
(DNStateManager... sms) Method to insert an array of objects to the datastore.void
Locates this object in the datastore.default void
locateObjects
(DNStateManager[] sms) Locates object(s) in the datastore.void
updateObject
(DNStateManager sm, int[] fieldNumbers) Updates a persistent object in the datastore.
-
Method Details
-
close
void close()Method to close the persistence handler, and release any resources. -
batchStart
default void batchStart(ExecutionContext ec, StorePersistenceHandler.PersistenceBatchType batchType) Signal that a batch of operations are starting for the specified ExecutionContext. The batch type allows the store plugin to create whatever type of batch it needs.- Parameters:
ec
- The ExecutionContextbatchType
- Type of this batch that is starting
-
batchEnd
Signal that the current batch of operations are ending for the specified ExecutionContext.- Parameters:
ec
- The ExecutionContexttype
- Type of batch that is ending
-
insertObject
Inserts a persistent object into the database.- Parameters:
sm
- StateManager of the object to be inserted.- Throws:
NucleusDataStoreException
- when an error occurs in the datastore communication
-
insertObjects
Method to insert an array of objects to the datastore.- Parameters:
sms
- StateManagers for the objects to insert
-
updateObject
Updates a persistent object in the datastore.- Parameters:
sm
- StateManager of the object to be updated.fieldNumbers
- The numbers of the fields to be updated.- Throws:
NucleusDataStoreException
- when an error occurs in the datastore communication
-
deleteObject
Deletes a persistent object from the datastore.- Parameters:
sm
- StateManager of the object to be deleted.- Throws:
NucleusDataStoreException
- when an error occurs in the datastore communication
-
deleteObjects
Method to delete an array of objects from the datastore.- Parameters:
sms
- StateManagers for the objects to delete
-
fetchObject
Fetches specified fields of a persistent object from the database.- Parameters:
sm
- StateManager of the object to be fetched.fieldNumbers
- The numbers of the fields to be fetched.- Throws:
NucleusObjectNotFoundException
- if the object doesn't existNucleusDataStoreException
- when an error occurs in the datastore communication
-
fetchObjects
Fetches specified fields of several persistent objects (of the same type) from the database.- Parameters:
fieldNumbers
- The numbers of the fields to be fetched.sms
- StateManagers of the objects to be fetched.- Throws:
NucleusObjectNotFoundException
- if the object doesn't existNucleusDataStoreException
- when an error occurs in the datastore communication
-
locateObject
Locates this object in the datastore.- Parameters:
sm
- StateManager for the object to be found- Throws:
NucleusObjectNotFoundException
- if the object doesn't existNucleusDataStoreException
- when an error occurs in the datastore communication
-
locateObjects
Locates object(s) in the datastore.- Parameters:
sms
- StateManagers for the object(s) to be found- Throws:
NucleusObjectNotFoundException
- if an object doesn't existNucleusDataStoreException
- when an error occurs in the datastore communication
-
findObject
Method to find a persistable object with the specified id from the datastore, if the StoreManager supports this operation (optional). This allows for datastores that perform the instantiation of objects directly (such as ODBMS). With other types of datastores (e.g RDBMS) this method returns null.- Parameters:
ec
- The ExecutionContextid
- the id of the object in question.- Returns:
- a persistable object with a valid object state (for example: hollow) or null, indicating that the implementation leaves the instantiation work to DataNucleus.
- Throws:
NucleusObjectNotFoundException
- if this route is supported yet the object doesn't existNucleusDataStoreException
- when an error occurs in the datastore communication
-
findObjects
Method to find an array of objects with the specified identities from the datastore. This allows for datastores that perform the instantiation of objects directly (such as ODBMS). With other types of datastores (e.g RDBMS) this method returns null.- Parameters:
ec
- The ExecutionContextids
- identities of the object(s) to retrieve- Returns:
- The persistable objects with these identities (in the same order as
ids
) - Throws:
NucleusObjectNotFoundException
- if an object doesn't existNucleusDataStoreException
- when an error occurs in the datastore communication
-
findObjectForUnique
Object findObjectForUnique(ExecutionContext ec, AbstractClassMetaData cmd, String[] memberNames, Object[] values) Method to find the object with the specified value(s) for the member(s) of the specified type.- Parameters:
ec
- ExecutionContextcmd
- Metadata for the class in questionmemberNames
- Member(s) that define the objectvalues
- Value(s) for the member(s)- Returns:
- The object with these member value(s)
- Throws:
NucleusObjectNotFoundException
- if an object doesn't existNucleusDataStoreException
- when an error occurs in the datastore communication
-