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)
     {
     }
     
    • 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 ExecutionContext
        batchType - Type of this batch that is starting
      • insertObject

        void insertObject​(DNStateManager sm)
        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

        default void insertObjects​(DNStateManager... sms)
        Method to insert an array of objects to the datastore.
        Parameters:
        sms - StateManagers for the objects to insert
      • updateObject

        void updateObject​(DNStateManager sm,
                          int[] fieldNumbers)
        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

        void deleteObject​(DNStateManager sm)
        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

        default void deleteObjects​(DNStateManager... sms)
        Method to delete an array of objects from the datastore.
        Parameters:
        sms - StateManagers for the objects to delete
      • fetchObject

        void fetchObject​(DNStateManager sm,
                         int[] fieldNumbers)
        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 exist
        NucleusDataStoreException - when an error occurs in the datastore communication
      • fetchObjects

        default void fetchObjects​(int[] fieldNumbers,
                                  DNStateManager... sms)
        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 exist
        NucleusDataStoreException - 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 ExecutionContext
        id - 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 exist
        NucleusDataStoreException - 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 ExecutionContext
        ids - 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 exist
        NucleusDataStoreException - 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 - ExecutionContext
        cmd - Metadata for the class in question
        memberNames - Member(s) that define the object
        values - Value(s) for the member(s)
        Returns:
        The object with these member value(s)
        Throws:
        NucleusObjectNotFoundException - if an object doesn't exist
        NucleusDataStoreException - when an error occurs in the datastore communication