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 anMapStore
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 Summary
Fields Modifier and Type Field Description protected int
keyFieldNumber
Field number of key in value class (when key stored in value).protected DatastoreClass
mapTable
Table 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 void
clear(org.datanucleus.state.DNStateManager sm)
void
clearKeyOfValue(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.SetStore
entrySetStore()
protected SelectStatement
getSQLStatementForGet(org.datanucleus.state.DNStateManager ownerSM)
Method to return an SQLStatement for retrieving the value for a key.protected V
getValue(org.datanucleus.state.DNStateManager ownerSM, Object key)
Method to retrieve a value from the Map given the key.protected void
initialise()
org.datanucleus.store.types.scostore.SetStore
keySetStore()
V
put(org.datanucleus.state.DNStateManager sm, K newKey, V newValue)
V
remove(org.datanucleus.state.DNStateManager sm, Object key)
void
remove(org.datanucleus.state.DNStateManager sm, Object key, Object oldValue)
boolean
updateEmbeddedKey(org.datanucleus.state.DNStateManager sm, Object key, int fieldNumber, Object newValue)
boolean
updateEmbeddedValue(org.datanucleus.state.DNStateManager sm, Object value, int fieldNumber, Object newValue)
protected boolean
updateKeyFkInternal(org.datanucleus.state.DNStateManager sm, Object key, Object owner)
protected boolean
updateValueFkInternal(org.datanucleus.state.DNStateManager sm, Object value, Object owner)
protected void
validateValueType(org.datanucleus.ClassLoaderResolver clr, Object value)
Utility to validate the type of a value for storing in the Map.org.datanucleus.store.types.scostore.CollectionStore
valueCollectionStore()
-
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:
validateValueType
in 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:
getValue
in 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)
-
-