org.datanucleus.store.rdbms
Class RDBMSPersistenceHandler

java.lang.Object
  extended by org.datanucleus.store.rdbms.RDBMSPersistenceHandler
All Implemented Interfaces:
org.datanucleus.store.StorePersistenceHandler

public class RDBMSPersistenceHandler
extends java.lang.Object
implements org.datanucleus.store.StorePersistenceHandler

Handler for persistence for RDBMS datastores. Makes use of the plugin-point "org.datanucleus.store.rdbms.rdbms_request" defining which request handlers we should use for the different operations.


Field Summary
protected static org.datanucleus.util.Localiser LOCALISER
          Localiser for messages.
protected  org.datanucleus.store.mapped.MappedStoreManager storeMgr
          Manager for the store.
 
Constructor Summary
RDBMSPersistenceHandler(org.datanucleus.store.StoreManager storeMgr)
          Constructor.
 
Method Summary
 void close()
          Method to close the handler and release any resources.
 void deleteObject(org.datanucleus.StateManager sm)
          Deletes a persistent object from the database.
 void fetchObject(org.datanucleus.StateManager sm, int[] fieldNumbers)
          Fetches a persistent object from the database.
 java.lang.Object findObject(org.datanucleus.ObjectManager om, java.lang.Object id)
          Method to return a persistable object with the specified id.
 void insertObject(org.datanucleus.StateManager sm)
          Inserts a persistent object into the database.
 void locateObject(org.datanucleus.StateManager sm)
          Locates this object in the datastore.
 void removeAllRequests()
          Convenience method to remove all requests since the schema has changed.
 void removeRequestsForTable(org.datanucleus.store.mapped.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.StateManager sm, int[] fieldNumbers)
          Updates a persistent object in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final org.datanucleus.util.Localiser LOCALISER
Localiser for messages.


storeMgr

protected final org.datanucleus.store.mapped.MappedStoreManager storeMgr
Manager for the store.

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.

Specified by:
close in interface org.datanucleus.store.StorePersistenceHandler

insertObject

public void insertObject(org.datanucleus.StateManager sm)
Inserts a persistent object into the database.

Specified by:
insertObject in interface org.datanucleus.store.StorePersistenceHandler
Parameters:
sm - The state manager of the object to be inserted.
Throws:
org.datanucleus.exceptions.NucleusDataStoreException - when an error occurs in the datastore communication

fetchObject

public void fetchObject(org.datanucleus.StateManager sm,
                        int[] fieldNumbers)
Fetches a persistent object from the database.

Specified by:
fetchObject in interface org.datanucleus.store.StorePersistenceHandler
Parameters:
sm - The state manager of the object to be fetched.
fieldNumbers - The numbers of the fields to be fetched.
Throws:
org.datanucleus.exceptions.NucleusObjectNotFoundException - if the object doesnt exist
org.datanucleus.exceptions.NucleusDataStoreException - when an error occurs in the datastore communication

updateObject

public void updateObject(org.datanucleus.StateManager sm,
                         int[] fieldNumbers)
Updates a persistent object in the database.

Specified by:
updateObject in interface org.datanucleus.store.StorePersistenceHandler
Parameters:
sm - The state manager of 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.StateManager sm)
Deletes a persistent object from the database.

Specified by:
deleteObject in interface org.datanucleus.store.StorePersistenceHandler
Parameters:
sm - The state manager of the object to be deleted.
Throws:
org.datanucleus.exceptions.NucleusDataStoreException - when an error occurs in the datastore communication

locateObject

public void locateObject(org.datanucleus.StateManager sm)
Locates this object in the datastore.

Specified by:
locateObject in interface org.datanucleus.store.StorePersistenceHandler
Parameters:
sm - The 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 java.lang.Object findObject(org.datanucleus.ObjectManager om,
                                   java.lang.Object id)
Method to return a persistable object with the specified id. Optional operation for StoreManagers. Should return a (at least) hollow PersistenceCapable 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.

Specified by:
findObject in interface org.datanucleus.store.StorePersistenceHandler
Parameters:
om - the ObjectManager which will manage the object
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(org.datanucleus.store.mapped.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


Copyright © 2009. All Rights Reserved.