org.datanucleus.store.rdbms
Class RDBMSPersistenceHandler

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

public class RDBMSPersistenceHandler
extends org.datanucleus.store.AbstractPersistenceHandler

Handler for persistence for RDBMS datastores.


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.store.ObjectProvider op)
          Deletes a persistent object from the database.
 void fetchObject(org.datanucleus.store.ObjectProvider op, int[] memberNumbers)
          Fetches (fields of) a persistent object from the database.
 Object findObject(org.datanucleus.store.ExecutionContext ec, Object id)
          Method to return a persistable object with the specified id.
 void insertObject(org.datanucleus.store.ObjectProvider op)
          Inserts a persistent object into the database.
 void locateObject(org.datanucleus.store.ObjectProvider op)
          Locates this object in the datastore.
 void locateObjects(org.datanucleus.store.ObjectProvider[] ops)
           
 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.store.ObjectProvider op, int[] fieldNumbers)
          Updates a persistent object in the database.
 boolean useReferentialIntegrity()
           
 
Methods inherited from class org.datanucleus.store.AbstractPersistenceHandler
batchEnd, batchStart, deleteObjects, findObjects, insertObjects
 
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.


useReferentialIntegrity

public boolean useReferentialIntegrity()
Specified by:
useReferentialIntegrity in interface org.datanucleus.store.StorePersistenceHandler
Overrides:
useReferentialIntegrity in class org.datanucleus.store.AbstractPersistenceHandler

insertObject

public void insertObject(org.datanucleus.store.ObjectProvider op)
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:
op - The ObjectProvider 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.store.ObjectProvider op,
                        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 neccessary to retrieve those objects.

Parameters:
op - Object Provider 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.store.ObjectProvider op,
                         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:
op - The ObjectProvider 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.store.ObjectProvider op)
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:
op - The ObjectProvider of the object to be deleted.
Throws:
org.datanucleus.exceptions.NucleusDataStoreException - when an error occurs in the datastore communication

locateObjects

public void locateObjects(org.datanucleus.store.ObjectProvider[] ops)
Specified by:
locateObjects in interface org.datanucleus.store.StorePersistenceHandler
Overrides:
locateObjects in class org.datanucleus.store.AbstractPersistenceHandler

locateObject

public void locateObject(org.datanucleus.store.ObjectProvider op)
Locates this object in the datastore.

Parameters:
op - ObjectProvider 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.store.ExecutionContext ec,
                         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.

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(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 © 2012. All Rights Reserved.