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>
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.DNStateManager sm)voidclearKeyOfValue(org.datanucleus.state.DNStateManager sm, Object key, Object oldValue)Utility to clear the key of a value from the Map.org.datanucleus.store.types.scostore.SetStoreentrySetStore()protected SelectStatementgetSQLStatementForGet(org.datanucleus.state.DNStateManager ownerSM)Method to return an SQLStatement for retrieving the value for a key.protected VgetValue(org.datanucleus.state.DNStateManager ownerSM, Object key)Method to retrieve a value from the Map given the key.protected voidinitialise()org.datanucleus.store.types.scostore.SetStorekeySetStore()Vput(org.datanucleus.state.DNStateManager sm, K newKey, V newValue)Vremove(org.datanucleus.state.DNStateManager sm, Object key)voidremove(org.datanucleus.state.DNStateManager sm, Object key, Object oldValue)booleanupdateEmbeddedKey(org.datanucleus.state.DNStateManager sm, Object key, int fieldNumber, Object newValue)booleanupdateEmbeddedValue(org.datanucleus.state.DNStateManager sm, Object value, int fieldNumber, Object newValue)protected booleanupdateKeyFkInternal(org.datanucleus.state.DNStateManager sm, Object key, Object owner)protected booleanupdateValueFkInternal(org.datanucleus.state.DNStateManager sm, 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()-
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, getOwnerMapping, getOwnerMemberMetaData, getRelationType, getStateManagerForEmbeddedPCObject, 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
-
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 objectoldValue- 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:
getValuein classAbstractMapStore<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)
-
-