Package org.datanucleus.store.federation
Class FederatedPersistenceHandler
- java.lang.Object
-
- org.datanucleus.store.federation.FederatedPersistenceHandler
-
- All Implemented Interfaces:
StorePersistenceHandler
public class FederatedPersistenceHandler extends Object implements StorePersistenceHandler
Persistence handler for federated datastores. Distributes the inserts/updates/deletes/fetches to the appropriate datastore.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.datanucleus.store.StorePersistenceHandler
StorePersistenceHandler.PersistenceBatchType
-
-
Constructor Summary
Constructors Constructor Description FederatedPersistenceHandler(StoreManager storeMgr)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
batchEnd(ExecutionContext ec, StorePersistenceHandler.PersistenceBatchType type)
Signal that the current batch of operations are ending for the specified ExecutionContext.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(DNStateManager sm)
Deletes a persistent object from the datastore.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.void
fetchObjects(int[] fieldNumbers, DNStateManager... sms)
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.Object[]
findObjects(ExecutionContext ec, Object[] ids)
Method to find an array of objects with the specified identities from the datastore.void
insertObject(DNStateManager sm)
Inserts a persistent object into the database.void
insertObjects(DNStateManager... sms)
Method to insert an array of objects to the datastore.void
locateObject(DNStateManager sm)
Locates this object in the datastore.void
locateObjects(DNStateManager[] sms)
Locates object(s) in the datastore.void
updateObject(DNStateManager sm, int[] fieldNumbers)
Updates a persistent object in the datastore.boolean
useReferentialIntegrity()
-
-
-
Constructor Detail
-
FederatedPersistenceHandler
public FederatedPersistenceHandler(StoreManager storeMgr)
Constructor.- Parameters:
storeMgr
- StoreManager
-
-
Method Detail
-
close
public void close()
Description copied from interface:StorePersistenceHandler
Method to close the persistence handler, and release any resources.- Specified by:
close
in interfaceStorePersistenceHandler
-
useReferentialIntegrity
public boolean useReferentialIntegrity()
-
insertObjects
public void insertObjects(DNStateManager... sms)
Description copied from interface:StorePersistenceHandler
Method to insert an array of objects to the datastore.- Specified by:
insertObjects
in interfaceStorePersistenceHandler
- Parameters:
sms
- StateManagers for the objects to insert
-
deleteObjects
public void deleteObjects(DNStateManager... sms)
Description copied from interface:StorePersistenceHandler
Method to delete an array of objects from the datastore.- Specified by:
deleteObjects
in interfaceStorePersistenceHandler
- Parameters:
sms
- StateManagers for the objects to delete
-
batchStart
public void batchStart(ExecutionContext ec, StorePersistenceHandler.PersistenceBatchType batchType)
Description copied from interface:StorePersistenceHandler
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.- Specified by:
batchStart
in interfaceStorePersistenceHandler
- Parameters:
ec
- The ExecutionContextbatchType
- Type of this batch that is starting
-
batchEnd
public void batchEnd(ExecutionContext ec, StorePersistenceHandler.PersistenceBatchType type)
Description copied from interface:StorePersistenceHandler
Signal that the current batch of operations are ending for the specified ExecutionContext.- Specified by:
batchEnd
in interfaceStorePersistenceHandler
- Parameters:
ec
- The ExecutionContexttype
- Type of batch that is ending
-
insertObject
public void insertObject(DNStateManager sm)
Description copied from interface:StorePersistenceHandler
Inserts a persistent object into the database.- Specified by:
insertObject
in interfaceStorePersistenceHandler
- Parameters:
sm
- StateManager of the object to be inserted.
-
updateObject
public void updateObject(DNStateManager sm, int[] fieldNumbers)
Description copied from interface:StorePersistenceHandler
Updates a persistent object in the datastore.- Specified by:
updateObject
in interfaceStorePersistenceHandler
- Parameters:
sm
- StateManager of the object to be updated.fieldNumbers
- The numbers of the fields to be updated.
-
deleteObject
public void deleteObject(DNStateManager sm)
Description copied from interface:StorePersistenceHandler
Deletes a persistent object from the datastore.- Specified by:
deleteObject
in interfaceStorePersistenceHandler
- Parameters:
sm
- StateManager of the object to be deleted.
-
fetchObject
public void fetchObject(DNStateManager sm, int[] fieldNumbers)
Description copied from interface:StorePersistenceHandler
Fetches specified fields of a persistent object from the database.- Specified by:
fetchObject
in interfaceStorePersistenceHandler
- Parameters:
sm
- StateManager of the object to be fetched.fieldNumbers
- The numbers of the fields to be fetched.
-
fetchObjects
public void fetchObjects(int[] fieldNumbers, DNStateManager... sms)
Description copied from interface:StorePersistenceHandler
Fetches specified fields of several persistent objects (of the same type) from the database.- Specified by:
fetchObjects
in interfaceStorePersistenceHandler
- Parameters:
fieldNumbers
- The numbers of the fields to be fetched.sms
- StateManagers of the objects to be fetched.
-
locateObject
public void locateObject(DNStateManager sm)
Description copied from interface:StorePersistenceHandler
Locates this object in the datastore.- Specified by:
locateObject
in interfaceStorePersistenceHandler
- Parameters:
sm
- StateManager for the object to be found
-
locateObjects
public void locateObjects(DNStateManager[] sms)
Description copied from interface:StorePersistenceHandler
Locates object(s) in the datastore.- Specified by:
locateObjects
in interfaceStorePersistenceHandler
- Parameters:
sms
- StateManagers for the object(s) to be found
-
findObject
public Object findObject(ExecutionContext ec, Object id)
Description copied from interface:StorePersistenceHandler
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.- Specified by:
findObject
in interfaceStorePersistenceHandler
- 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.
-
findObjects
public Object[] findObjects(ExecutionContext ec, Object[] ids)
Description copied from interface:StorePersistenceHandler
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.- Specified by:
findObjects
in interfaceStorePersistenceHandler
- Parameters:
ec
- The ExecutionContextids
- identities of the object(s) to retrieve- Returns:
- The persistable objects with these identities (in the same order as
ids
)
-
findObjectForUnique
public Object findObjectForUnique(ExecutionContext ec, AbstractClassMetaData cmd, String[] memberNames, Object[] values)
Description copied from interface:StorePersistenceHandler
Method to find the object with the specified value(s) for the member(s) of the specified type.- Specified by:
findObjectForUnique
in interfaceStorePersistenceHandler
- 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)
-
-