Class FetchPlanForClass


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

      • plan

        final FetchPlan plan
        Parent FetchPlan.
      • 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

        java.util.Map<java.lang.Integer,​java.lang.Integer> recursionDepthByMemberNumber
      • fetchGroupsByMemberNumber

        private java.util.Map<java.lang.Integer,​java.util.Set<FetchGroupMetaData>> fetchGroupsByMemberNumber
        Cache of fetch groups by member number, as calculating them in getFetchGroupsForMemberNumber() is O(n^2) Map>
    • Constructor Detail

      • FetchPlanForClass

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

      • 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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • markDirty

        void markDirty()
      • getCopy

        FetchPlanForClass getCopy​(FetchPlan fp)
        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 java.util.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 java.util.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 java.util.BitSet getMemberNumbersForFetchGroups​(java.util.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 java.util.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​(java.util.BitSet memberNums)
        Sets the given BitSet of member numbers to include the DFG members.
        Parameters:
        memberNums - BitSet of member numbers
      • setAsAll

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

        private void setAsNone​(java.util.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 java.util.Set<FetchGroupMetaData> getFetchGroupsForMemberNumber​(java.util.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