Class JoinSetStore<E>

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

    public class JoinSetStore<E>
    extends AbstractSetStore<E>
    Implementation of a SetStore using join table.
    • Field Detail

      • locateStmt

        protected String locateStmt
        Statement to check the existence of an owner-element relation.
      • maxOrderColumnIdStmt

        protected String maxOrderColumnIdStmt
        Statement to get the maximum order column id so we can set the next insert value.
    • Constructor Detail

      • JoinSetStore

        public JoinSetStore​(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                            CollectionTable joinTable,
                            org.datanucleus.ClassLoaderResolver clr)
        Constructor for a join set store for RDBMS.
        Parameters:
        mmd - Metadata for the member that has the set with join table
        joinTable - The join table
        clr - The ClassLoaderResolver
    • Method Detail

      • update

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

        public boolean add​(org.datanucleus.state.DNStateManager sm,
                           E element,
                           int size)
      • addAll

        public boolean addAll​(org.datanucleus.state.DNStateManager sm,
                              Collection<E> elements,
                              int size)
      • removeAll

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

        protected String getRemoveStmt​(Object element)
        Generate statement for deleting items from the Set. The EMBEDDEDFIELDX is only present when the elements are PC(embedded).
         DELETE FROM SETTABLE
         WHERE OWNERCOL=?
         AND ELEMENTCOL = ?
         [AND EMBEDDEDFIELD1 = ? AND EMBEDDEDFIELD2 = ? AND EMBEDDEDFIELD3 = ?]
         [AND RELATION_DISCRIM = ?]
         
        Overrides:
        getRemoveStmt in class AbstractCollectionStore<E>
        Parameters:
        element - The element to remove
        Returns:
        Statement for deleting items from the Set.
      • getRemoveAllStmt

        protected String getRemoveAllStmt​(org.datanucleus.state.DNStateManager sm,
                                          Collection elements)
        Generate statement for removing a collection of items from the Set.
         DELETE FROM SETTABLE
         WHERE (OWNERCOL=? AND ELEMENTCOL=?) OR
               (OWNERCOL=? AND ELEMENTCOL=?) OR
               (OWNERCOL=? AND ELEMENTCOL=?)
         
        Parameters:
        sm - StateManager for the owner
        elements - Collection of elements to remove
        Returns:
        Statement for deleting items from the Set.
      • doInternalAdd

        protected int[] doInternalAdd​(org.datanucleus.state.DNStateManager sm,
                                      E element,
                                      org.datanucleus.store.connection.ManagedConnection conn,
                                      boolean batched,
                                      int orderId,
                                      boolean executeNow)
      • getNextIDForOrderColumn

        protected int getNextIDForOrderColumn​(org.datanucleus.state.DNStateManager sm)
      • iterator

        public Iterator<E> iterator​(org.datanucleus.state.DNStateManager ownerSM)
        Description copied from class: ElementContainerStore
        Accessor for an iterator through the container elements.
        Specified by:
        iterator in interface org.datanucleus.store.types.scostore.CollectionStore<E>
        Specified by:
        iterator in class AbstractSetStore<E>
        Parameters:
        ownerSM - StateManager for the container.
        Returns:
        The Iterator
      • getIteratorStatement

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