Class FKMapStore<K,​V>

  • All Implemented Interfaces:
    org.datanucleus.store.types.scostore.MapStore<K,​V>, org.datanucleus.store.types.scostore.Store

    public class FKMapStore<K,​V>
    extends AbstractMapStore<K,​V>
    RDBMS-specific implementation of an MapStore where either the value has a FK to the owner (and the key stored in the value), or whether the key has a FK to the owner (and the value stored in the key).
    • Field Detail

      • mapTable

        protected DatastoreClass mapTable
        Table storing the values (either key table, or value table).
      • keyFieldNumber

        protected int keyFieldNumber
        Field number of key in value class (when key stored in value).
    • Constructor Detail

      • FKMapStore

        public FKMapStore​(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                          RDBMSStoreManager storeMgr,
                          org.datanucleus.ClassLoaderResolver clr)
        Constructor for the backing store for an FK Map for RDBMS.
        Parameters:
        mmd - Field Meta-Data for the Map field.
        storeMgr - The Store Manager we are using.
        clr - The ClassLoaderResolver
    • Method Detail

      • initialise

        protected void initialise()
      • validateValueType

        protected void validateValueType​(org.datanucleus.ClassLoaderResolver clr,
                                         Object value)
        Utility to validate the type of a value for storing in the Map.
        Overrides:
        validateValueType in class AbstractMapStore<K,​V>
        Parameters:
        value - The value to check.
        clr - The ClassLoaderResolver
      • put

        public V put​(org.datanucleus.state.ObjectProvider op,
                     K newKey,
                     V newValue)
        Method to put an item in the Map.
        Parameters:
        op - ObjectProvider for the map.
        newKey - The key to store the value against
        newValue - The value to store.
        Returns:
        The value stored.
      • remove

        public V remove​(org.datanucleus.state.ObjectProvider op,
                        Object key)
        Method to remove an entry from the map.
        Parameters:
        op - ObjectProvider for the map.
        key - Key of the entry to remove.
        Returns:
        The value that was removed.
      • remove

        public V remove​(org.datanucleus.state.ObjectProvider op,
                        Object key,
                        Object oldValue)
        Method to remove an entry from the map.
        Parameters:
        op - ObjectProvider for the map.
        key - Key of the entry to remove.
        Returns:
        The value that was removed.
      • clear

        public void clear​(org.datanucleus.state.ObjectProvider op)
        Method to clear the map of all values.
        Parameters:
        op - ObjectProvider for the map.
      • clearKeyOfValue

        public void clearKeyOfValue​(org.datanucleus.state.ObjectProvider op,
                                    Object key,
                                    Object oldValue)
        Utility to clear the key of a value from the Map. If the key is non nullable, delete the value.
        Parameters:
        op - ObjectProvider for the map.
        key - Key of the object
        oldValue - Value to remove
      • keySetStore

        public org.datanucleus.store.types.scostore.SetStore keySetStore()
        Accessor for the keys in the Map.
        Returns:
        The keys
      • valueCollectionStore

        public org.datanucleus.store.types.scostore.CollectionStore valueCollectionStore()
        Accessor for the values in the Map.
        Returns:
        The values.
      • entrySetStore

        public org.datanucleus.store.types.scostore.SetStore entrySetStore()
        Accessor for the map entries in the Map.
        Returns:
        The map entries.
      • updateValueFkInternal

        protected boolean updateValueFkInternal​(org.datanucleus.state.ObjectProvider op,
                                                Object value,
                                                Object owner)
      • updateKeyFkInternal

        protected boolean updateKeyFkInternal​(org.datanucleus.state.ObjectProvider op,
                                              Object key,
                                              Object owner)
      • getValue

        protected V getValue​(org.datanucleus.state.ObjectProvider ownerOP,
                             Object key)
                      throws NoSuchElementException
        Method to retrieve a value from the Map given the key.
        Specified by:
        getValue in class AbstractMapStore<K,​V>
        Parameters:
        ownerOP - ObjectProvider for the owner of the map.
        key - The key to retrieve the value for.
        Returns:
        The value for this key
        Throws:
        NoSuchElementException - if the key was not found
      • getSQLStatementForGet

        protected SelectStatement getSQLStatementForGet​(org.datanucleus.state.ObjectProvider ownerOP)
        Method to return an SQLStatement for retrieving the value for a key. Selects the join table and optionally joins to the value table if it has its own table.
        Parameters:
        ownerOP - ObjectProvider for the owning object
        Returns:
        The SQLStatement
      • updateEmbeddedKey

        public boolean updateEmbeddedKey​(org.datanucleus.state.ObjectProvider op,
                                         Object key,
                                         int fieldNumber,
                                         Object newValue)
      • updateEmbeddedValue

        public boolean updateEmbeddedValue​(org.datanucleus.state.ObjectProvider op,
                                           Object value,
                                           int fieldNumber,
                                           Object newValue)