Class FKListStore<E>

  • All Implemented Interfaces:
    org.datanucleus.store.types.scostore.CollectionStore<E>, org.datanucleus.store.types.scostore.ListStore<E>, org.datanucleus.store.types.scostore.Store

    public class FKListStore<E>
    extends AbstractListStore<E>
    Implementation of a ListStore using foreign keys.
    • Constructor Detail

      • FKListStore

        public FKListStore​(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                           RDBMSStoreManager storeMgr,
                           org.datanucleus.ClassLoaderResolver clr)
        Parameters:
        mmd - Metadata for owning field/property
        storeMgr - Manager for the datastore
        clr - ClassLoader resolver
    • Method Detail

      • set

        public E set​(org.datanucleus.state.DNStateManager ownerSM,
                     int index,
                     Object element,
                     boolean allowDependentField)
      • update

        public void update​(org.datanucleus.state.DNStateManager ownerSM,
                           Collection coll)
        Specified by:
        update in interface org.datanucleus.store.types.scostore.CollectionStore<E>
        Overrides:
        update in class AbstractCollectionStore<E>
      • internalAdd

        protected boolean internalAdd​(org.datanucleus.state.DNStateManager ownerSM,
                                      int startAt,
                                      boolean atEnd,
                                      Collection<E> c,
                                      int size)
        Internal method for adding item(s) to the List as a specific position.
        Specified by:
        internalAdd in class AbstractListStore<E>
        Parameters:
        ownerSM - StateManager for the owner
        startAt - The start position
        atEnd - Whether to add at the end
        c - The Collection of elements to add.
        size - Current size of list (if known). -1 if not known
        Returns:
        Whether it was successful
      • remove

        public E remove​(org.datanucleus.state.DNStateManager ownerSM,
                        int index,
                        int size)
      • removeAll

        public boolean removeAll​(org.datanucleus.state.DNStateManager ownerSM,
                                 Collection elements,
                                 int size)
      • removeAll

        public boolean removeAll​(org.datanucleus.state.DNStateManager ownerSM,
                                 Collection elements,
                                 int size,
                                 int[] elementIndices)
      • internalRemove

        protected boolean internalRemove​(org.datanucleus.state.DNStateManager ownerSM,
                                         Object element,
                                         int size)
        Convenience method to remove the specified element from the List.
        Specified by:
        internalRemove in class AbstractListStore<E>
        Parameters:
        ownerSM - StateManager for the owner
        element - The element
        size - Current size of list if known. -1 if not known
        Returns:
        Whether the List was modified
      • internalRemoveAt

        protected void internalRemoveAt​(org.datanucleus.state.DNStateManager ownerSM,
                                        int index,
                                        int size)
        Internal method to remove an object at a location in the List. Differs from the JoinTable List in that it typically nulls out the owner FK (unless not nullable).
        Parameters:
        ownerSM - StateManager for the owner
        index - The location
        size - Current size of list (if known). -1 if not known
      • internalRemoveAtNullify

        protected void internalRemoveAtNullify​(org.datanucleus.state.DNStateManager ownerSM,
                                               int index,
                                               org.datanucleus.store.connection.ManagedConnection mconn,
                                               boolean batched,
                                               boolean executeNow)
        Internal method to remove an object at a location in the List by nulling its owner and setting its List index to -1.
        Parameters:
        ownerSM - StateManager for the list owner
        index - The index to nullify
        mconn - Managed Connection to use for datastore connectivity
        batched - Whether this statement should be batched
        executeNow - Whether we should execute this statement now
      • internalRemoveAtNullifyBulk

        protected void internalRemoveAtNullifyBulk​(org.datanucleus.state.DNStateManager ownerSM,
                                                   int[] indices,
                                                   org.datanucleus.store.connection.ManagedConnection mconn,
                                                   boolean batched,
                                                   boolean executeNow)
        Internal method to remove an object at a location in the List by nulling its owner and setting its List index to -1.
        Parameters:
        ownerSM - StateManager for the list owner
        indices - The indexes to nullify
        mconn - Managed Connection to use for datastore connectivity
        batched - Whether this statement should be batched
        executeNow - Whether we should execute this statement now
      • clear

        public void clear​(org.datanucleus.state.DNStateManager ownerSM)
        Method to clear the List. This is called by the List.clear() method, or when the container object is being deleted and the elements are to be removed (maybe for dependent field), or also when updating a Collection and removing all existing prior to adding all new.
        Specified by:
        clear in interface org.datanucleus.store.types.scostore.CollectionStore<E>
        Overrides:
        clear in class ElementContainerStore
        Parameters:
        ownerSM - StateManager for the owner
      • validateElementForWriting

        protected boolean validateElementForWriting​(org.datanucleus.state.DNStateManager ownerSM,
                                                    Object element,
                                                    int index)
        Method to validate that an element is valid for writing to the datastore. TODO Minimise differences to super.validateElementForWriting()
        Parameters:
        ownerSM - StateManager for the List owner
        element - The element to validate
        index - The position that the element is being stored at in the list
        Returns:
        Whether the element was inserted
      • listIterator

        protected ListIterator<E> listIterator​(org.datanucleus.state.DNStateManager ownerSM,
                                               int startIdx,
                                               int endIdx)
        Accessor for an iterator through the list elements.
        Specified by:
        listIterator in class AbstractListStore<E>
        Parameters:
        ownerSM - StateManager for the owner.
        startIdx - The start index in the list (only for indexed lists)
        endIdx - The end index in the list (only for indexed lists)
        Returns:
        The List Iterator
      • getIteratorStatement

        public ElementIteratorStatement getIteratorStatement​(org.datanucleus.ExecutionContext ec,
                                                             org.datanucleus.FetchPlan fp,
                                                             boolean addRestrictionOnOwner,
                                                             int startIdx,
                                                             int endIdx)
        Method to return the SQLStatement and mapping for an iterator for this backing store. Create a statement of the form
         SELECT ELEM_COLS
         FROM ELEM_TBL
         [WHERE]
           [ELEM_TBL.OWNER_ID = {value}] [AND]
           [ELEM_TBL.DISCRIM = {discrimValue}]
         [ORDER BY {orderClause}]
         
        This is public to provide access for BulkFetchXXXHandler class(es).
        Parameters:
        ec - ExecutionContext
        fp - FetchPlan to use in determing which fields of element to select
        addRestrictionOnOwner - Whether to restrict to a particular owner (otherwise functions as bulk fetch for many owners).
        startIdx - Start index for the iterator (or -1)
        endIdx - End index for the iterator (or -1)
        Returns:
        The SQLStatement and its associated StatementClassMapping