Class FetchRequest

java.lang.Object
org.datanucleus.store.rdbms.request.Request
org.datanucleus.store.rdbms.request.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.

  • Field Details

    • statementUnlocked

      private String statementUnlocked
      JDBC fetch statement without locking.
    • statementLocked

      private String statementLocked
      JDBC fetch statement with locking.
    • memberNumbersToFetch

      private int[] memberNumbersToFetch
      Absolute numbers of the fields/properties of the class to fetch.
    • memberNumbersToStore

      private int[] memberNumbersToStore
      Absolute numbers of the members of the class to store the value for.
    • mappingDefinition

      private StatementClassMapping mappingDefinition
      The mapping of the results of the SQL statement.
    • mappingCallbacks

      private final List<MappingCallbacks> mappingCallbacks
      Callbacks for postFetch() operations, to be called after the fetch itself (relation fields).
    • numberOfFieldsToFetch

      private int numberOfFieldsToFetch
    • fieldsToFetch

      private final String fieldsToFetch
      Convenience string listing the fields to be fetched by this request.
    • fetchingSurrogateVersion

      private boolean fetchingSurrogateVersion
      Whether we are fetching a surrogate version in this fetch.
    • versionFieldName

      private String versionFieldName
      Name of the version field. Only applies if the class has a version field (not surrogate).
  • Constructor Details

    • FetchRequest

      public FetchRequest(DatastoreClass classTable, org.datanucleus.FetchPlanForClass fpClass, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.metadata.AbstractMemberMetaData[] mmds, org.datanucleus.metadata.AbstractMemberMetaData[] mmdsToStore)
      Constructor. Uses the structure of the datastore table to build a basic SELECT query.
      Parameters:
      classTable - The Class Table representing the datastore table to retrieve
      fpClass - FetchPlan for class
      clr - ClassLoader resolver
      cmd - ClassMetaData of the candidate
      mmds - MetaData of the members to fetch
      mmdsToStore - MetaData of the members to store
  • Method Details

    • 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.FetchPlanForClass fpClass, org.datanucleus.metadata.AbstractMemberMetaData[] mmds, org.datanucleus.metadata.AbstractMemberMetaData[] mmdsToStore, DatastoreClass table, SQLTable sqlTbl, StatementClassMapping mappingDef, Collection<MappingCallbacks> fetchCallbacks, org.datanucleus.ClassLoaderResolver clr, List<Integer> memberNumbersToStore)
      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
      fpClass - FetchPlan for class
      mmds - MetaData for the members to fetch
      mmdsToStore - MetaData for the members to store
      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
      memberNumbersToStore - Numbers of the members that need storing (populated by this call)
      Returns:
      Number of members being selected in the statement
    • processMemberToFetch

      boolean processMemberToFetch(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.FetchPlanForClass fpClass, org.datanucleus.ClassLoaderResolver clr, Collection<MappingCallbacks> fetchCallbacks, SelectStatement sqlStmt, SQLTable sqlTbl, StatementClassMapping mappingDef, List<Integer> memberNumbersToStore)
      Method to process the specified member.
      Parameters:
      mmd - MetaData for the member
      fpClass - FetchPlan for class
      clr - ClassLoader resolver
      fetchCallbacks - Any fetch callbacks to register the mapping with
      sqlStmt - The SELECT statement
      sqlTbl - The SQL table (of the candidate)
      mappingDef - The mapping definition for this statement
      memberNumbersToStore - List of member numbers that are approved to be stored (any fetched ones will be added if recursionDepth=0)
      store - Whether we are just selecting the value of this member for storing (rather than fetching)
      Returns:
      Whether this member is selected in the statement
    • processMemberToStore

      boolean processMemberToStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, org.datanucleus.FetchPlanForClass fpClass, org.datanucleus.ClassLoaderResolver clr, Collection<MappingCallbacks> fetchCallbacks, SelectStatement sqlStmt, SQLTable sqlTbl, StatementClassMapping mappingDef, List<Integer> memberNumbersToStore)
      Method to process the specified member.
      Parameters:
      mmd - MetaData for the member
      fpClass - FetchPlan for class
      clr - ClassLoader resolver
      fetchCallbacks - Any fetch callbacks to register the mapping with
      sqlStmt - The SELECT statement
      sqlTbl - The SQL table (of the candidate)
      mappingDef - The mapping definition for this statement
      memberNumbersToStore - List of member numbers that are approved to be stored
      Returns:
      Whether this member is selected in the statement