Class ResultMetaDataROF

java.lang.Object
org.datanucleus.store.rdbms.query.AbstractROF
org.datanucleus.store.rdbms.query.ResultMetaDataROF
All Implemented Interfaces:
ResultObjectFactory

public class ResultMetaDataROF extends AbstractROF
ResultObjectFactory that operates using a QueryResultMetaData and returns objects based on the definition. A QueryResultMetaData allows for a row of a ResultSet to be returned as a mix of :-
  • a number of persistent objects (made up of several ResultSet columns)
  • a number of Objects (from individual ResultSet columns)
Each call to getObject() will then return a set of objects as per the MetaData definition.

ResultSet to object mapping

Each row of the ResultSet has a set of columns, and these columns are either used for direct outputting back to the user as a "simple" object, or as a field in a persistent object. So you could have a situation like this :-
 ResultSet Column   Output Object
 ================   =============
 COL1               PC1.field1
 COL2               PC1.field2
 COL3               Simple Object
 COL4               PC2.field3
 COL5               PC2.field1
 COL6               PC2.field2
 COL7               Simple Object
 COL8               PC1.field3
 ...
 
So this example will return an Object[4] comprised of Object[0] = instance of PC1, Object[1] = instance of PC2, Object[2] = simple object, Object[3] = simple object. When creating the instance of PC1 we take the ResultSet columns (COL1, COL2, COL8). When creating the instance of PC2 we take the ResultSet columns (COL5, COL6, COL4).

Columns to persistable object mapping

Where we have a number of columns forming a persistable object, such as (COL1, COL2, COL8) above we make use of ResultSetGetter to populate the fields of the persistable object from the ResultSet.
  • Field Details

    • queryResultMetaData

      org.datanucleus.metadata.QueryResultMetaData queryResultMetaData
      MetaData defining the result from the Query.
    • columnNames

      String[] columnNames
      Column names in the ResultSet.
    • persistentTypeResultSetGetters

      protected ResultSetGetter[] persistentTypeResultSetGetters
      ResultSetGetter objects used for any persistable objects in the result. Set when processing the first row.
  • Constructor Details

    • ResultMetaDataROF

      public ResultMetaDataROF(org.datanucleus.ExecutionContext ec, ResultSet rs, org.datanucleus.FetchPlan fp, org.datanucleus.metadata.QueryResultMetaData qrmd)
      Constructor.
      Parameters:
      ec - ExecutionContext
      rs - ResultSet
      fp - FetchPlan
      qrmd - MetaData defining the results from the query.
  • Method Details

    • getResultSet

      public ResultSet getResultSet()
      Description copied from interface: ResultObjectFactory
      Accessor for the JDBC ResultSet being processed.
      Specified by:
      getResultSet in interface ResultObjectFactory
      Overrides:
      getResultSet in class AbstractROF
      Returns:
      The ResultSet
    • getObject

      public Object getObject()
      Accessor for the object(s) from the current row of the ResultSet.
      Returns:
      The object(s) for this row of the ResultSet.