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 StatementClassMapping
private StatementParameterMapping
private String
JDBC statement to use for retrieving the value of the map for a key (locking).private String
JDBC statement to use for retrieving the value of the map for a key (not locking).protected int
Field number of key in value class (when key stored in value).protected DatastoreClass
Table storing the values (either key table, or value table).private final int
Field number of owner link in key/value class.private String
Statement for updating a foreign key for the map.private int
Field number of value in key class (when value stored in key).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
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 TypeMethodDescriptionvoid
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.protected SelectStatement
getSQLStatementForGet
(org.datanucleus.state.DNStateManager ownerSM) Method to return an SQLStatement for retrieving the value for a key.private String
Generate statement for updating a Foreign Key from key/value to owner in an inverse 1-N.protected V
Method to retrieve a value from the Map given the key.protected void
org.datanucleus.store.types.scostore.SetStore
<K> void
private void
removeValue
(org.datanucleus.state.DNStateManager sm, Object key, Object oldValue) Utility to remove a value from the Map.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) private boolean
updateKeyFk
(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 boolean
updateKeyFkInternal
(org.datanucleus.state.DNStateManager sm, Object key, Object owner) private boolean
updateValueFk
(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 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
<V> 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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.datanucleus.store.types.scostore.MapStore
put, putAll, update
Methods 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:
validateValueType
in classAbstractMapStore<K,
V> - Parameters:
clr
- The ClassLoaderResolvervalue
- The value to check.
-
put
-
remove
-
remove
-
removeValue
Utility to remove a value from the Map.- Parameters:
sm
- StateManager for the map.key
- Key of the objectoldValue
- Value to remove
-
clear
public void clear(org.datanucleus.state.DNStateManager sm) -
clearKeyOfValue
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
-
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:
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
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
-