Class FetchRequest


  • public class FetchRequest
    extends Request
    Class to retrieve the fields of an object of a specified class from the datastore. If some of those fields are themselves persistent objects then this can optionally retrieve fields of those objects in the same fetch.

    Any surrogate version stored in this table will be fetched *if* the object being updated doesn't already have a value for it. If the caller wants the surrogate version to be updated then they should nullify the "transactional" version before calling.

    • Constructor Detail

      • FetchRequest

        public FetchRequest​(DatastoreClass classTable,
                            org.datanucleus.metadata.AbstractMemberMetaData[] mmds,
                            org.datanucleus.metadata.AbstractClassMetaData cmd,
                            org.datanucleus.ClassLoaderResolver clr)
        Constructor, taking the table. Uses the structure of the datastore table to build a basic query.
        Parameters:
        classTable - The Class Table representing the datastore table to retrieve
        mmds - MetaData of the fields/properties to retrieve
        cmd - ClassMetaData of objects being fetched
        clr - ClassLoader resolver
    • Method Detail

      • execute

        public void execute​(org.datanucleus.state.DNStateManager sm)
        Description copied from class: Request
        Method to execute the request - to be implemented by deriving classes.
        Specified by:
        execute in class Request
        Parameters:
        sm - StateManager for the object in question.
      • processMembersOfClass

        protected int processMembersOfClass​(SelectStatement sqlStatement,
                                            org.datanucleus.metadata.AbstractMemberMetaData[] mmds,
                                            DatastoreClass table,
                                            SQLTable sqlTbl,
                                            StatementClassMapping mappingDef,
                                            Collection fetchCallbacks,
                                            org.datanucleus.ClassLoaderResolver clr)
        Method to process the supplied members of the class, adding to the SQLStatement as required. Can recurse if some of the requested fields are persistent objects in their own right, so we take the opportunity to retrieve some of their fields.
        Parameters:
        sqlStatement - Statement being built
        mmds - Meta-data for the required fields/properties
        table - The table to look for member mappings
        sqlTbl - The table in the SQL statement to use for selects
        mappingDef - Mapping definition for the result
        fetchCallbacks - Any additional required callbacks are added here
        clr - ClassLoader resolver
        Returns:
        Number of fields being fetched