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
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 Summary
FieldsModifier and TypeFieldDescriptionprivate StatementClassMappingprivate StatementParameterMappingprivate StringJDBC statement to use for retrieving the value of the map for a key (locking).private StringJDBC statement to use for retrieving the value of the map for a key (not locking).protected intField number of key in value class (when key stored in value).protected DatastoreClassTable storing the values (either key table, or value table).private final intField number of owner link in key/value class.private StringStatement for updating a foreign key for the map.private intField number of value in key class (when value stored in key).Fields inherited from class AbstractMapStore
containsValueStmt, iterateUsingDiscriminator, keyCmd, keyMapping, keysAreEmbedded, keysAreSerialised, keyType, valueCmd, valueMapping, valuesAreEmbedded, valuesAreSerialised, valueTypeFields inherited from class BaseContainerStore
allowNulls, clr, dba, ownerMapping, ownerMemberMetaData, relationType, storeMgr -
Constructor Summary
ConstructorsConstructorDescriptionFKMapStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr) Constructor for the backing store for an FK Map for RDBMS. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear(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.protected SelectStatementgetSQLStatementForGet(org.datanucleus.state.DNStateManager ownerSM) Method to return an SQLStatement for retrieving the value for a key.private StringGenerate statement for updating a Foreign Key from key/value to owner in an inverse 1-N.protected VMethod to retrieve a value from the Map given the key.protected voidorg.datanucleus.store.types.scostore.SetStore<K> voidprivate voidremoveValue(org.datanucleus.state.DNStateManager sm, Object key, Object oldValue) Utility to remove a value from the Map.booleanupdateEmbeddedKey(org.datanucleus.state.DNStateManager sm, Object key, int fieldNumber, Object newValue) booleanupdateEmbeddedValue(org.datanucleus.state.DNStateManager sm, Object value, int fieldNumber, Object newValue) private booleanupdateKeyFk(org.datanucleus.state.DNStateManager sm, Object key, Object owner) Utility to update a foreign-key in the key in the case of a unidirectional 1-N relationship.protected booleanupdateKeyFkInternal(org.datanucleus.state.DNStateManager sm, Object key, Object owner) private booleanupdateValueFk(org.datanucleus.state.DNStateManager sm, Object value, Object owner) Utility to update a foreign-key in the value in the case of a unidirectional 1-N relationship.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.CollectionStore<V> Methods inherited from class AbstractMapStore
containsKey, containsValue, get, getContainsValueStmt, getKeyClassMetaData, getKeyMapping, getValueClassMetaData, getValueMapping, keysAreEmbedded, keysAreSerialised, putAll, validateKeyForReading, validateKeyForWriting, validateKeyType, validateValueForReading, validateValueForWriting, valuesAreEmbedded, valuesAreSerialisedMethods inherited from class BaseContainerStore
allowsBatching, getComponentInformationForClass, getDatastoreAdapter, getOwnerMapping, getOwnerMemberMetaData, getRelationType, getStateManagerForEmbeddedPCObject, getStoreManager, isEmbeddedMapping, setOwnerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.datanucleus.store.types.scostore.MapStore
put, putAll, updateMethods inherited from interface org.datanucleus.store.types.scostore.Store
getOwnerMemberMetaData, getStoreManager
-
Field Details
-
mapTable
Table storing the values (either key table, or value table). -
updateFkStmt
Statement for updating a foreign key for the map. -
getStmtLocked
JDBC statement to use for retrieving the value of the map for a key (locking). -
getStmtUnlocked
JDBC statement to use for retrieving the value of the map for a key (not locking). -
getMappingDef
-
getMappingParams
-
ownerFieldNumber
private final int ownerFieldNumberField number of owner link in key/value class. -
keyFieldNumber
protected int keyFieldNumberField number of key in value class (when key stored in value). -
valueFieldNumber
private int valueFieldNumberField number of value in key class (when value stored in key).
-
-
Constructor Details
-
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 Details
-
initialise
protected void initialise() -
updateValueFk
Utility to update a foreign-key in the value in the case of a unidirectional 1-N relationship.- Parameters:
sm- StateManager for the ownervalue- The value to updateowner- The owner object to set in the FK- Returns:
- Whether it was performed successfully
-
updateKeyFk
Utility to update a foreign-key in the key in the case of a unidirectional 1-N relationship.- Parameters:
sm- StateManager for the ownerkey- The key to updateowner- The owner object to set in the FK- Returns:
- Whether it was performed successfully
-
validateValueType
Utility to validate the type of a value for storing in the Map.- Overrides:
validateValueTypein classAbstractMapStore<K,V> - Parameters:
clr- The ClassLoaderResolvervalue- The value to check.
-
put
-
remove
-
remove
-
removeValue
-
clear
public void clear(org.datanucleus.state.DNStateManager sm) -
clearKeyOfValue
-
keySetStore
-
valueCollectionStore
-
entrySetStore
-
getUpdateFkStmt
Generate statement for updating a Foreign Key from key/value to owner in an inverse 1-N.UPDATE MAPTABLE SET FK_COL_1 = ?, FK_COL_2 = ? WHERE ELEMENT_ID = ?
- Returns:
- Statement for updating the FK in an inverse 1-N
-
updateValueFkInternal
-
updateKeyFkInternal
-
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
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
-
updateEmbeddedValue
-