Class FetchPlanForClass

java.lang.Object
org.datanucleus.FetchPlanForClass

public class FetchPlanForClass extends Object
Representation of the fetch plan for a particular class, defining the members that are to be fetched.
  • Field Details

    • plan

      final FetchPlan plan
      Parent FetchPlan.
    • cmd

      MetaData for the class that this represents.
    • memberNumbers

      int[] memberNumbers
      Absolute numbers of fields/properties in the fetch plan for this class.
    • dirty

      boolean dirty
      Whether the record is dirty and needs the fields recalculating.
    • recursionDepthByMemberNumber

      Map<Integer,Integer> recursionDepthByMemberNumber
    • fetchGroupsByMemberNumber

      private Map<Integer,Set<FetchGroupMetaData>> fetchGroupsByMemberNumber
      Cache of fetch groups by member number, as calculating them in getFetchGroupsForMemberNumber() is O(n^2) Mapinvalid input: '<'Integer, Set>
  • Constructor Details

    • FetchPlanForClass

      public FetchPlanForClass(AbstractClassMetaData cmd, FetchPlan fetchPlan)
      Constructor.
      Parameters:
      cmd - MetaData for the class
      fetchPlan - the FetchPlan
  • Method Details

    • getFetchPlan

      public final FetchPlan getFetchPlan()
      Accessor for the FetchPlan that this classes plan relates to.
      Returns:
      The FetchPlan
    • getAbstractClassMetaData

      public final AbstractClassMetaData getAbstractClassMetaData()
      Accessor for the MetaData for this classes plan.
      Returns:
      MetaData for the class represented here
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • markDirty

      void markDirty()
    • getCopy

      Returns a copy of this object with all settings initialised. Used when a Query has to have its own FetchPlan, so takes a copy of that of the ExecutionContext.
      Returns:
      the FetchPlanForClass copy
    • getRecursionDepthForMember

      public int getRecursionDepthForMember(int memberNum)
      Method to return the recursion depth of this member number in the overall fetch plan.
      Parameters:
      memberNum - Number of member in this class
      Returns:
      The recursion depth
    • hasMember

      public boolean hasMember(int memberNumber)
      Return whether the specified field/property is in the fetch plan
      Parameters:
      memberNumber - The member number
      Returns:
      Whether it is in the FetchPlan
    • getMemberNumbers

      public int[] getMemberNumbers()
      Get the absolute numbers of the members in the fetch plan for this class.
      Returns:
      an array with the absolute position of the members
    • getMemberNumbersByBitSet

      public BitSet getMemberNumbersByBitSet()
      Get all members (of this class, and superclasses) in the fetch plan.
      Returns:
      an BitSet with the bits set in the absolute position of the fields
    • getMemberNumbersByBitSet

      private BitSet getMemberNumbersByBitSet(AbstractClassMetaData cmd)
      Get all members in the fetch plan for this class and superclasses.
      Parameters:
      cmd - metadata for the class
      Returns:
      an BitSet with the bits set in the absolute position of the members
    • getMemberNumbersForFetchGroups

      private BitSet getMemberNumbersForFetchGroups(Set<FetchGroupMetaData> fgmds)
      Get the absolute number of the members for an array of Fetch Group.
      Parameters:
      fgmds - The Fetch Groups
      Returns:
      a BitSet with flags set to true in the member number positions
    • getMemberNumbersForFetchGroup

      private BitSet getMemberNumbersForFetchGroup(FetchGroupMetaData fgmd)
      Get the absolute member numbers for a particular Fetch Group.
      Parameters:
      fgmd - The Fetch Group
      Returns:
      a list of member numbers
    • setAsDefault

      private void setAsDefault(BitSet memberNums)
      Sets the given BitSet of member numbers to include the DFG members.
      Parameters:
      memberNums - BitSet of member numbers
    • setAsAll

      private void setAsAll(BitSet memberNums)
      Sets the given BitSet of member numbers to include all the members.
      Parameters:
      memberNums - BitSet of member numbers
    • setAsNone

      private void setAsNone(BitSet memberNums)
      Sets the given BitSet of member numbers to include none of the members (except the PKs).
      Parameters:
      memberNums - BitSet of member numbers
    • isToCallPostLoadFetchPlan

      public boolean isToCallPostLoadFetchPlan(boolean[] loadedMembers)
      Whether to call the post load or not. Checks if members in actual FetchPlan where not previouly loaded and the post-load is enabled in the metadata.
      Parameters:
      loadedMembers - already loaded members
      Returns:
      if is to call the postLoad
    • getFetchGroupsForMemberNumber

      private Set<FetchGroupMetaData> getFetchGroupsForMemberNumber(Set<FetchGroupMetaData> fgmds, int memberNum)
      Get all the (MetaData-based) fetch groups where this member number is included.
      Parameters:
      fgmds - The Fetch Groups
      memberNum - the member absolute number
      Returns:
      The Fetch Groups