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 signaturepublic MyPersistenceHandler(StoreManager storeMgr) { }
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
StorePersistenceHandler.PersistenceBatchType
Enum for the type of a batched operation
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
batchEnd(ExecutionContext ec, StorePersistenceHandler.PersistenceBatchType type)
Signal that the current batch of operations are ending for the specified ExecutionContext.default void
batchStart(ExecutionContext ec, StorePersistenceHandler.PersistenceBatchType batchType)
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
deleteObject(ObjectProvider op)
Deletes a persistent object from the datastore.default void
deleteObjects(ObjectProvider... ops)
Method to delete an array of objects from the datastore.void
fetchObject(ObjectProvider op, int[] fieldNumbers)
Fetches specified fields of a persistent object from the database.default void
fetchObjects(int[] fieldNumbers, ObjectProvider... ops)
Fetches specified fields of several persistent objects (of the same type) from the database.Object
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).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.default Object[]
findObjects(ExecutionContext ec, Object[] ids)
Method to find an array of objects with the specified identities from the datastore.void
insertObject(ObjectProvider op)
Inserts a persistent object into the database.default void
insertObjects(ObjectProvider... ops)
Method to insert an array of objects to the datastore.void
locateObject(ObjectProvider op)
Locates this object in the datastore.default void
locateObjects(ObjectProvider[] ops)
Locates object(s) in the datastore.void
updateObject(ObjectProvider op, int[] fieldNumbers)
Updates a persistent object in the datastore.
-
-
-
Method Detail
-
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
default void batchEnd(ExecutionContext ec, StorePersistenceHandler.PersistenceBatchType type)
Signal that the current batch of operations are ending for the specified ExecutionContext.- Parameters:
ec
- The ExecutionContexttype
- Type of batch that is ending
-
insertObject
void insertObject(ObjectProvider op)
Inserts a persistent object into the database.- Parameters:
op
- The ObjectProvider of the object to be inserted.- Throws:
NucleusDataStoreException
- when an error occurs in the datastore communication
-
insertObjects
default void insertObjects(ObjectProvider... ops)
Method to insert an array of objects to the datastore.- Parameters:
ops
- ObjectProviders for the objects to insert
-
updateObject
void updateObject(ObjectProvider op, int[] fieldNumbers)
Updates a persistent object in the datastore.- Parameters:
op
- The ObjectProvider 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
void deleteObject(ObjectProvider op)
Deletes a persistent object from the datastore.- Parameters:
op
- The ObjectProvider of the object to be deleted.- Throws:
NucleusDataStoreException
- when an error occurs in the datastore communication
-
deleteObjects
default void deleteObjects(ObjectProvider... ops)
Method to delete an array of objects from the datastore.- Parameters:
ops
- ObjectProviders for the objects to delete
-
fetchObject
void fetchObject(ObjectProvider op, int[] fieldNumbers)
Fetches specified fields of a persistent object from the database.- Parameters:
op
- The ObjectProvider 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
default void fetchObjects(int[] fieldNumbers, ObjectProvider... ops)
Fetches specified fields of several persistent objects (of the same type) from the database.- Parameters:
fieldNumbers
- The numbers of the fields to be fetched.ops
- The ObjectProviders of the objects to be fetched.- Throws:
NucleusObjectNotFoundException
- if the object doesn't existNucleusDataStoreException
- when an error occurs in the datastore communication
-
locateObject
void locateObject(ObjectProvider op)
Locates this object in the datastore.- Parameters:
op
- The ObjectProvider for the object to be found- Throws:
NucleusObjectNotFoundException
- if the object doesn't existNucleusDataStoreException
- when an error occurs in the datastore communication
-
locateObjects
default void locateObjects(ObjectProvider[] ops)
Locates object(s) in the datastore.- Parameters:
ops
- ObjectProvider(s) for the object(s) to be found- Throws:
NucleusObjectNotFoundException
- if an object doesn't existNucleusDataStoreException
- when an error occurs in the datastore communication
-
findObject
Object 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). 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
default Object[] findObjects(ExecutionContext ec, Object[] ids)
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
-
-