Class FKMapStore<K,V>
- java.lang.Object
-
- org.datanucleus.store.rdbms.scostore.BaseContainerStore
-
- org.datanucleus.store.rdbms.scostore.AbstractMapStore<K,V>
-
- org.datanucleus.store.rdbms.scostore.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 anMapStorewhere 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 Summary
Fields Modifier and Type Field Description protected intkeyFieldNumberField number of key in value class (when key stored in value).protected DatastoreClassmapTableTable storing the values (either key table, or value table).-
Fields inherited from class org.datanucleus.store.rdbms.scostore.AbstractMapStore
containsValueStmt, iterateUsingDiscriminator, keyCmd, keyMapping, keysAreEmbedded, keysAreSerialised, keyType, valueCmd, valueMapping, valuesAreEmbedded, valuesAreSerialised, valueType
-
Fields inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowNulls, clr, dba, ownerMapping, ownerMemberMetaData, relationType, storeMgr
-
-
Constructor Summary
Constructors Constructor Description FKMapStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)Constructor for the backing store for an FK Map for RDBMS.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear(org.datanucleus.state.ObjectProvider op)Method to clear the map of all values.voidclearKeyOfValue(org.datanucleus.state.ObjectProvider op, Object key, Object oldValue)Utility to clear the key of a value from the Map.org.datanucleus.store.types.scostore.SetStoreentrySetStore()Accessor for the map entries in the Map.protected SelectStatementgetSQLStatementForGet(org.datanucleus.state.ObjectProvider ownerOP)Method to return an SQLStatement for retrieving the value for a key.protected VgetValue(org.datanucleus.state.ObjectProvider ownerOP, Object key)Method to retrieve a value from the Map given the key.protected voidinitialise()org.datanucleus.store.types.scostore.SetStorekeySetStore()Accessor for the keys in the Map.Vput(org.datanucleus.state.ObjectProvider op, K newKey, V newValue)Method to put an item in the Map.Vremove(org.datanucleus.state.ObjectProvider op, Object key)Method to remove an entry from the map.Vremove(org.datanucleus.state.ObjectProvider op, Object key, Object oldValue)Method to remove an entry from the map.booleanupdateEmbeddedKey(org.datanucleus.state.ObjectProvider op, Object key, int fieldNumber, Object newValue)booleanupdateEmbeddedValue(org.datanucleus.state.ObjectProvider op, Object value, int fieldNumber, Object newValue)protected booleanupdateKeyFkInternal(org.datanucleus.state.ObjectProvider op, Object key, Object owner)protected booleanupdateValueFkInternal(org.datanucleus.state.ObjectProvider op, Object value, Object owner)protected voidvalidateValueType(org.datanucleus.ClassLoaderResolver clr, Object value)Utility to validate the type of a value for storing in the Map.org.datanucleus.store.types.scostore.CollectionStorevalueCollectionStore()Accessor for the values in the Map.-
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractMapStore
containsKey, containsValue, get, getContainsValueStmt, getKeyClassMetaData, getKeyMapping, getValueClassMetaData, getValueMapping, keysAreEmbedded, keysAreSerialised, putAll, validateKeyForReading, validateKeyForWriting, validateKeyType, validateValueForReading, validateValueForWriting, valuesAreEmbedded, valuesAreSerialised
-
Methods inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowsBatching, getComponentInformationForClass, getDatastoreAdapter, getObjectProviderForEmbeddedPCObject, getOwnerMapping, getOwnerMemberMetaData, getRelationType, getStoreManager, isEmbeddedMapping, setOwner
-
-
-
-
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:
validateValueTypein classAbstractMapStore<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 againstnewValue- 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 objectoldValue- 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:
getValuein classAbstractMapStore<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)
-
-