Class ResultClassROF

  • All Implemented Interfaces:
    ResultObjectFactory

    public class ResultClassROF
    extends AbstractROF
    Take a ResultSet, and for each row retrieves an object of a specified result class type. Follows the rules in the JDO 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

    • Simple type - String, Long, Integer, Float, Boolean, Byte, Character, Double, Short, BigDecimal, BigInteger, java.util.Date, java.sql.Date, java.sql.Time, java.sql.Timestamp
    • java.util.Map - DataNucleus will choose the concrete impl of java.util.Map to use
    • Object[]
    • User defined type with either a constructor taking the result set fields, or a default constructor and setting the fields using a put(Object,Object) method, setXXX methods, or public fields

    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.

    • Constructor Detail

      • ResultClassROF

        public ResultClassROF​(org.datanucleus.ExecutionContext ec,
                              ResultSet rs,
                              org.datanucleus.FetchPlan fp,
                              Class cls,
                              StatementResultMapping resultDefinition)
        Constructor for a resultClass object factory where we have a result clause specified.
        Parameters:
        ec - ExecutionContext
        rs - ResultSet being processed
        fp - FetchPlan
        cls - The result class to use (if any)
        resultDefinition - The mapping information for the result expressions
      • ResultClassROF

        public ResultClassROF​(org.datanucleus.ExecutionContext ec,
                              ResultSet rs,
                              Class cls,
                              StatementClassMapping classDefinition)
        Constructor for a resultClass object factory where we have no result clause specified but a result class. In this case the result will match the candidate class, but may not be the actual candidate class (e.g Object[])
        Parameters:
        ec - ExecutionContext
        rs - ResultSet being processed
        cls - The result class to use
        classDefinition - The mapping information for the (candidate) class
      • ResultClassROF

        public ResultClassROF​(org.datanucleus.ExecutionContext ec,
                              ResultSet rs,
                              Class cls,
                              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:
        ec - ExecutionContext
        rs - ResultSet being processed
        cls - The result class to use
        resultFieldNames - Names for the result fields
    • Method Detail

      • getObject

        public Object getObject()
        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.
        Returns:
        The ResultClass object.
      • getValueForNewObject

        protected Object getValueForNewObject​(StatementNewObjectMapping newMap,
                                              org.datanucleus.ExecutionContext ec,
                                              ResultSet rs)
        Convenience method to return the value of a NewObject mapping for the current row of the provided query results.
        Parameters:
        newMap - new object mapping
        ec - ExecutionContext
        rs - Query results
        Returns:
        The value of the new object