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>
    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.DNStateManager sm,
                     K newKey,
                     V newValue)
      • remove

        public V remove​(org.datanucleus.state.DNStateManager sm,
                        Object key)
      • remove

        public void remove​(org.datanucleus.state.DNStateManager sm,
                           Object key,
                           Object oldValue)
      • clear

        public void clear​(org.datanucleus.state.DNStateManager sm)
      • clearKeyOfValue

        public void clearKeyOfValue​(org.datanucleus.state.DNStateManager sm,
                                    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:
        sm - StateManager for the map.
        key - Key of the object
        oldValue - Value to remove
      • keySetStore

        public org.datanucleus.store.types.scostore.SetStore keySetStore()
      • valueCollectionStore

        public org.datanucleus.store.types.scostore.CollectionStore valueCollectionStore()
      • entrySetStore

        public org.datanucleus.store.types.scostore.SetStore entrySetStore()
      • updateValueFkInternal

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

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

        protected V getValue​(org.datanucleus.state.DNStateManager ownerSM,
                             Object key)
                      throws NoSuchElementException
        Method to retrieve a value from the Map given the key.
        Specified by:
        getValue in class AbstractMapStore<K,​V>
        Parameters:
        ownerSM - StateManager 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.DNStateManager ownerSM)
        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:
        ownerSM - StateManager for the owning object
        Returns:
        The SQLStatement
      • updateEmbeddedKey

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

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