org.datanucleus.store.rdbms.query
Class PersistentClassROF

java.lang.Object
  extended by org.datanucleus.store.rdbms.query.PersistentClassROF
All Implemented Interfaces:
org.datanucleus.store.query.ResultObjectFactory

public final class PersistentClassROF
extends Object
implements org.datanucleus.store.query.ResultObjectFactory

ResultObjectFactory that takes a JDBC ResultSet and create a PersistenceCapable object instance for each row in the ResultSet. We use information in the result set to determine the object type; this can be a discriminator column, or can be a special "NucleusType" column defined just for result processing.


Field Summary
protected  org.datanucleus.metadata.AbstractClassMetaData acmd
          Metadata for the persistent class.
protected  org.datanucleus.FetchPlan fetchPlan
          Fetch Plan to use when loading fields (if any).
protected static org.datanucleus.util.Localiser LOCALISER
          Localiser for messages.
protected  org.datanucleus.store.mapped.StatementClassMapping stmtMapping
          Mapping for the statement to members of this class (and sub-objects).
protected  RDBMSStoreManager storeMgr
           
 
Constructor Summary
PersistentClassROF(RDBMSStoreManager storeMgr, org.datanucleus.metadata.AbstractClassMetaData acmd, org.datanucleus.store.mapped.StatementClassMapping mappingDefinition, boolean ignoreCache, org.datanucleus.FetchPlan fetchPlan, Class persistentClass)
          Constructor.
 
Method Summary
static Object getDatastoreIdentityForResultSetRow(org.datanucleus.store.ExecutionContext ec, org.datanucleus.metadata.AbstractClassMetaData cmd, Class pcClass, boolean inheritanceCheck, Object resultSet, org.datanucleus.store.mapped.StatementClassMapping mappingDefinition)
          Method to return the object datastore identity for a row of the result set.
static Object getIdentityForResultSetRow(RDBMSStoreManager storeMgr, Object resultSet, org.datanucleus.store.mapped.StatementClassMapping mappingDefinition, org.datanucleus.store.ExecutionContext ec, org.datanucleus.metadata.AbstractClassMetaData cmd, Class pcClass, boolean inheritanceCheck)
          Method to return the object identity for a row of the result set.
 Object getObject(org.datanucleus.store.ExecutionContext ec, Object rs)
          Method to convert the current ResultSet row into an Object.
 void setPersistentClass(Class cls)
          Method to update the persistent class that the result object factory requires.
 
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 RDBMSStoreManager storeMgr

acmd

protected final org.datanucleus.metadata.AbstractClassMetaData acmd
Metadata for the persistent class.


stmtMapping

protected org.datanucleus.store.mapped.StatementClassMapping stmtMapping
Mapping for the statement to members of this class (and sub-objects).


fetchPlan

protected final org.datanucleus.FetchPlan fetchPlan
Fetch Plan to use when loading fields (if any).

Constructor Detail

PersistentClassROF

public PersistentClassROF(RDBMSStoreManager storeMgr,
                          org.datanucleus.metadata.AbstractClassMetaData acmd,
                          org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
                          boolean ignoreCache,
                          org.datanucleus.FetchPlan fetchPlan,
                          Class persistentClass)
Constructor.

Parameters:
storeMgr - RDBMS StoreManager
acmd - MetaData for the class (base class)
mappingDefinition - Mapping information for the result set and how it maps to the class
ignoreCache - Whether to ignore the cache
fetchPlan - the Fetch Plan
persistentClass - Class that this factory will create instances of (or subclasses)
Method Detail

setPersistentClass

public void setPersistentClass(Class cls)
Method to update the persistent class that the result object factory requires. This is used where we have an Extent(BaseClass) and we pass it to a JDOQL query but the query has been specified with a persistent class that is a subclass. So we use this method to restrict the results further.

Parameters:
cls - The Class the result factory requires.

getObject

public Object getObject(org.datanucleus.store.ExecutionContext ec,
                        Object rs)
Method to convert the current ResultSet row into an Object.

Specified by:
getObject in interface org.datanucleus.store.query.ResultObjectFactory
Parameters:
ec - execution context
rs - The ResultSet from the Query.
Returns:
The (persisted) object.

getIdentityForResultSetRow

public static Object getIdentityForResultSetRow(RDBMSStoreManager storeMgr,
                                                Object resultSet,
                                                org.datanucleus.store.mapped.StatementClassMapping mappingDefinition,
                                                org.datanucleus.store.ExecutionContext ec,
                                                org.datanucleus.metadata.AbstractClassMetaData cmd,
                                                Class pcClass,
                                                boolean inheritanceCheck)
Method to return the object identity for a row of the result set.

Parameters:
storeMgr - RDBMS StoreManager
resultSet - Result set
mappingDefinition - Mapping definition for the candidate class
ec - Execution Context
cmd - Metadata for the class
pcClass - The class required
inheritanceCheck - Whether need an inheritance check (may be for a subclass)
Returns:
The identity (if found) or null (if either not sure of inheritance, or not known).

getDatastoreIdentityForResultSetRow

public static Object getDatastoreIdentityForResultSetRow(org.datanucleus.store.ExecutionContext ec,
                                                         org.datanucleus.metadata.AbstractClassMetaData cmd,
                                                         Class pcClass,
                                                         boolean inheritanceCheck,
                                                         Object resultSet,
                                                         org.datanucleus.store.mapped.StatementClassMapping mappingDefinition)
Method to return the object datastore identity for a row of the result set. If the class isn't using datastore identity then returns null

Parameters:
ec - Execution Context
cmd - Metadata for the class
pcClass - The class required
inheritanceCheck - Whether need an inheritance check (may be for a subclass)
resultSet - Result set
mappingDefinition - Mapping definition for the candidate class
Returns:
The identity (if found) or null (if either not sure of inheritance, or not known).


Copyright © 2012. All Rights Reserved.