org.datanucleus.store.rdbms.query
Class ResultClassROF

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

public class ResultClassROF
extends java.lang.Object
implements org.datanucleus.store.query.ResultObjectFactory

Take a ResultSet, and for each row retrieves an object of a specified type. Follows the rules in JDO2 spec [14.6.12] regarding the result class.

The resultClass will be used to create objects of that type when calling getObject(). The resultClass can be one of the following

Objects of this class are created in 2 distinct situations. The first is where a candidate class is available, and consequently field position mappings are available. The second is where no candidate class is available and so only the field names are available, and the results are taken in ResultSet order. These 2 modes have their own constructor.


Field Summary
protected static org.datanucleus.util.Localiser LOCALISER
           
 
Constructor Summary
ResultClassROF(java.lang.Class cls, org.datanucleus.store.mapped.StatementClassMapping classDefinition)
          Constructor for a resultClass object factory where we have no result clause specified, so the result will be appropriate for the candidate class.
ResultClassROF(java.lang.Class cls, org.datanucleus.store.mapped.StatementMappingIndex[] resultMappings, org.datanucleus.store.mapped.expression.ScalarExpression[] expressions)
          Constructor for cases where we have a candidate class and so have mapping information to base field positions on.
ResultClassROF(java.lang.Class cls, org.datanucleus.store.mapped.StatementResultMapping resultDefinition)
          Constructor for a resultClass object factory where we have a result clause specified.
ResultClassROF(java.lang.Class cls, java.lang.String[] resultFieldNames)
          Constructor for cases where we have no candidate class and so have no mapping information to base field positions on.
 
Method Summary
 java.lang.Object getObject(org.datanucleus.ObjectManager om, java.lang.Object rs)
          Method to convert the ResultSet row into an Object of the ResultClass type.
protected  java.lang.Object getValueForNewObject(org.datanucleus.store.mapped.StatementNewObjectMapping newMap, org.datanucleus.ObjectManager om, java.lang.Object results)
          Convenience method to return the value of a NewObject mapping for the current row of the provided query results.
 
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
Constructor Detail

ResultClassROF

public ResultClassROF(java.lang.Class cls,
                      org.datanucleus.store.mapped.StatementResultMapping resultDefinition)
Constructor for a resultClass object factory where we have a result clause specified.

Parameters:
cls - The result class to use (if any)
resultDefinition - The mapping information for the result expressions

ResultClassROF

public ResultClassROF(java.lang.Class cls,
                      org.datanucleus.store.mapped.StatementClassMapping classDefinition)
Constructor for a resultClass object factory where we have no result clause specified, so the result will be appropriate for the candidate class.

Parameters:
cls - The result class to use
classDefinition - The mapping information for the (candidate) class

ResultClassROF

public ResultClassROF(java.lang.Class cls,
                      org.datanucleus.store.mapped.StatementMappingIndex[] resultMappings,
                      org.datanucleus.store.mapped.expression.ScalarExpression[] expressions)
Constructor for cases where we have a candidate class and so have mapping information to base field positions on. TODO Remove this when we remove the legacy JDOQL process

Parameters:
cls - The result class to use
resultMappings - The mapping information for field positions etc
expressions - The result expressions (if known)

ResultClassROF

public ResultClassROF(java.lang.Class cls,
                      java.lang.String[] resultFieldNames)
Constructor for cases where we have no candidate class and so have no mapping information to base field positions on. The fields will be retrieved in the ResultSet order. Used for SQL queries.

Parameters:
cls - The result class to use
resultFieldNames - Names for the result fields
Method Detail

getObject

public java.lang.Object getObject(org.datanucleus.ObjectManager om,
                                  java.lang.Object rs)
Method to convert the ResultSet row into an Object of the ResultClass type. We have a special handling for "result" expressions when they include literals or "new Object()" expression due to the fact that complex literals and "new Object()" cannot be added to the SQL queries.

Specified by:
getObject in interface org.datanucleus.store.query.ResultObjectFactory
Parameters:
om - The ObjectManager
rs - The ResultSet from the Query.
Returns:
The ResultClass object.

getValueForNewObject

protected java.lang.Object getValueForNewObject(org.datanucleus.store.mapped.StatementNewObjectMapping newMap,
                                                org.datanucleus.ObjectManager om,
                                                java.lang.Object results)
Convenience method to return the value of a NewObject mapping for the current row of the provided query results.

Parameters:
newMap - new object mapping
om - ObjectManager
results - Query results
Returns:
The value of the new object


Copyright © 2009. All Rights Reserved.