Class RDBMSPersistenceHandler

  • All Implemented Interfaces:
    org.datanucleus.store.StorePersistenceHandler

    public class RDBMSPersistenceHandler
    extends org.datanucleus.store.AbstractPersistenceHandler
    Handler for persistence for RDBMS datastores.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.datanucleus.store.StorePersistenceHandler

        org.datanucleus.store.StorePersistenceHandler.PersistenceBatchType
    • Field Summary

      • Fields inherited from class org.datanucleus.store.AbstractPersistenceHandler

        storeMgr
    • Constructor Summary

      Constructors 
      Constructor Description
      RDBMSPersistenceHandler​(org.datanucleus.store.StoreManager storeMgr)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Method to close the handler and release any resources.
      void deleteObject​(org.datanucleus.state.DNStateManager sm)
      Deletes a persistent object from the database.
      void fetchObject​(org.datanucleus.state.DNStateManager sm, int[] memberNumbers)
      Fetches (fields of) a persistent object from the database.
      Object findObject​(org.datanucleus.ExecutionContext ec, Object id)
      Method to return a persistable object with the specified id.
      void insertObject​(org.datanucleus.state.DNStateManager sm)
      Inserts a persistent object into the database.
      void insertObjects​(org.datanucleus.state.DNStateManager... sms)  
      void locateObject​(org.datanucleus.state.DNStateManager sm)
      Locates this object in the datastore.
      void locateObjects​(org.datanucleus.state.DNStateManager[] sms)  
      void removeAllRequests()
      Convenience method to remove all requests since the schema has changed.
      void removeRequestsForTable​(DatastoreClass table)
      Convenience method to remove all requests that use a particular table since the structure of the table has changed potentially leading to missing columns in the cached version.
      void updateObject​(org.datanucleus.state.DNStateManager sm, int[] fieldNumbers)
      Updates a persistent object in the database.
      • Methods inherited from class org.datanucleus.store.AbstractPersistenceHandler

        assertReadOnlyForUpdateOfObject, findObjectForUnique
      • Methods inherited from interface org.datanucleus.store.StorePersistenceHandler

        batchEnd, batchStart, deleteObjects, fetchObjects, findObjects
    • Constructor Detail

      • RDBMSPersistenceHandler

        public RDBMSPersistenceHandler​(org.datanucleus.store.StoreManager storeMgr)
        Constructor.
        Parameters:
        storeMgr - StoreManager
    • Method Detail

      • close

        public void close()
        Method to close the handler and release any resources.
      • insertObjects

        public void insertObjects​(org.datanucleus.state.DNStateManager... sms)
      • insertObject

        public void insertObject​(org.datanucleus.state.DNStateManager sm)
        Inserts a persistent object into the database. The insert can take place in several steps, one insert per table that it is stored in. e.g When persisting an object that uses "new-table" inheritance for each level of the inheritance tree then will get an INSERT into each table. When persisting an object that uses "complete-table" inheritance then will get a single INSERT into its table.
        Parameters:
        sm - StateManager for the object to be inserted.
        Throws:
        org.datanucleus.exceptions.NucleusDataStoreException - when an error occurs in the datastore communication
      • fetchObject

        public void fetchObject​(org.datanucleus.state.DNStateManager sm,
                                int[] memberNumbers)
        Fetches (fields of) a persistent object from the database. This does a single SELECT on the candidate of the class in question. Will join to inherited tables as appropriate to get values persisted into other tables. Can also join to the tables of related objects (1-1, N-1) as necessary to retrieve those objects.
        Parameters:
        sm - StateManager of the object to be fetched.
        memberNumbers - The numbers of the members to be fetched.
        Throws:
        org.datanucleus.exceptions.NucleusObjectNotFoundException - if the object doesn't exist
        org.datanucleus.exceptions.NucleusDataStoreException - when an error occurs in the datastore communication
      • updateObject

        public void updateObject​(org.datanucleus.state.DNStateManager sm,
                                 int[] fieldNumbers)
        Updates a persistent object in the database. The update can take place in several steps, one update per table that it is stored in (depending on which fields are updated). e.g When updating an object that uses "new-table" inheritance for each level of the inheritance tree then will get an UPDATE into each table. When updating an object that uses "complete-table" inheritance then will get a single UPDATE into its table.
        Parameters:
        sm - StateManager for the object to be updated.
        fieldNumbers - The numbers of the fields to be updated.
        Throws:
        org.datanucleus.exceptions.NucleusDataStoreException - when an error occurs in the datastore communication
      • deleteObject

        public void deleteObject​(org.datanucleus.state.DNStateManager sm)
        Deletes a persistent object from the database. The delete can take place in several steps, one delete per table that it is stored in. e.g When deleting an object that uses "new-table" inheritance for each level of the inheritance tree then will get an DELETE for each table. When deleting an object that uses "complete-table" inheritance then will get a single DELETE for its table.
        Parameters:
        sm - StateManager for the object to be deleted.
        Throws:
        org.datanucleus.exceptions.NucleusDataStoreException - when an error occurs in the datastore communication
      • locateObjects

        public void locateObjects​(org.datanucleus.state.DNStateManager[] sms)
      • locateObject

        public void locateObject​(org.datanucleus.state.DNStateManager sm)
        Locates this object in the datastore.
        Parameters:
        sm - StateManager for the object to be found
        Throws:
        org.datanucleus.exceptions.NucleusObjectNotFoundException - if the object doesnt exist
        org.datanucleus.exceptions.NucleusDataStoreException - when an error occurs in the datastore communication
      • findObject

        public Object findObject​(org.datanucleus.ExecutionContext ec,
                                 Object id)
        Method to return a persistable object with the specified id. Optional operation for StoreManagers. Should return a (at least) hollow persistable object if the store manager supports the operation. If the StoreManager is managing the in-memory object instantiation (as part of co-managing the object lifecycle in general), then the StoreManager has to create the object during this call (if it is not already created). Most relational databases leave the in-memory object instantion to Core, but some object databases may manage the in-memory object instantion, effectively preventing Core of doing this.

        StoreManager implementations may simply return null, indicating that they leave the object instantiate to us. Other implementations may instantiate the object in question (whether the implementation may trust that the object is not already instantiated has still to be determined). If an implementation believes that an object with the given ID should exist, but in fact does not exist, then the implementation should throw a RuntimeException. It should not silently return null in this case.

        Parameters:
        ec - execution context
        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 us.
      • removeAllRequests

        public void removeAllRequests()
        Convenience method to remove all requests since the schema has changed.
      • removeRequestsForTable

        public void removeRequestsForTable​(DatastoreClass table)
        Convenience method to remove all requests that use a particular table since the structure of the table has changed potentially leading to missing columns in the cached version.
        Parameters:
        table - The table