Class MapEntrySetStore<K,V>
java.lang.Object
org.datanucleus.store.rdbms.scostore.BaseContainerStore
org.datanucleus.store.rdbms.scostore.MapEntrySetStore<K,V>
- All Implemented Interfaces:
org.datanucleus.store.types.scostore.CollectionStore<Map.Entry<K,V>>, org.datanucleus.store.types.scostore.SetStore<Map.Entry<K, V>>, org.datanucleus.store.types.scostore.Store
class MapEntrySetStore<K,V>
extends BaseContainerStore
implements org.datanucleus.store.types.scostore.SetStore<Map.Entry<K,V>>
RDBMS-specific implementation of a SetStore for map entries.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classInner class representing the entry in the map.static classInner class representing an iterator for the Set. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]private StatementParameterMappingprivate StringSQL statement to use for retrieving data from the map (locking).private StringSQL statement to use for retrieving data from the map (normal).private int[]protected JavaTypeMappingMapping for the key.The backing store for the Map.protected TableTable containing the key and value forming the entry.private Stringprotected JavaTypeMappingMapping for the value.Fields inherited from class BaseContainerStore
allowNulls, clr, dba, ownerMapping, ownerMemberMetaData, relationType, storeMgr -
Constructor Summary
ConstructorsConstructorDescriptionMapEntrySetStore(DatastoreClass mapTable, FKMapStore<K, V> mapStore, org.datanucleus.ClassLoaderResolver clr) Constructor for a store of the entries in a map when represented by either the key table or value table.MapEntrySetStore(MapTable mapTable, JoinMapStore<K, V> mapStore, org.datanucleus.ClassLoaderResolver clr) Constructor for a store of the entries in a map when represented in a join table. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(org.datanucleus.state.DNStateManager sm, Collection entries, int size) voidclear(org.datanucleus.state.DNStateManager sm) Method to clear the Map.booleanprivate StringMethod to return a size statement.protected SelectStatementgetSQLStatementForIterator(org.datanucleus.state.DNStateManager ownerSM, org.datanucleus.FetchPlan fp, boolean addRestrictionOnOwner) Method to generate a SelectStatement for iterating through entries of the map.booleaniterator(org.datanucleus.state.DNStateManager ownerSM) Method returning an iterator across the entries in the map for this owner object.booleanremove(org.datanucleus.state.DNStateManager sm, Object element, int size, boolean allowDependentField) Method to remove an entry from the Map.booleanremoveAll(org.datanucleus.state.DNStateManager sm, Collection elements, int size) Method to remove entries from the Map.intsize(org.datanucleus.state.DNStateManager sm) voidupdate(org.datanucleus.state.DNStateManager sm, Collection coll) Method to update the collection to be the supplied collection of elements.booleanupdateEmbeddedElement(org.datanucleus.state.DNStateManager sm, Map.Entry<K, V> element, int fieldNumber, Object value) Method to update an embedded element.protected booleanvalidateElementType(Object element) Methods inherited from class BaseContainerStore
allowsBatching, getComponentInformationForClass, getDatastoreAdapter, 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.Store
getOwnerMemberMetaData, getStoreManager
-
Field Details
-
mapTable
Table containing the key and value forming the entry. This may be a join table, or key table (with value "FK"), or value table (with key "FK"). -
mapStore
-
keyMapping
Mapping for the key. -
valueMapping
Mapping for the value. -
sizeStmt
-
iteratorSelectStmtSql
SQL statement to use for retrieving data from the map (normal). -
iteratorSelectStmtLockedSql
SQL statement to use for retrieving data from the map (locking). -
iteratorKeyResultCols
private int[] iteratorKeyResultCols -
iteratorValueResultCols
private int[] iteratorValueResultCols -
iteratorMappingParams
-
-
Constructor Details
-
MapEntrySetStore
MapEntrySetStore(MapTable mapTable, JoinMapStore<K, V> mapStore, org.datanucleus.ClassLoaderResolver clr) Constructor for a store of the entries in a map when represented in a join table.- Parameters:
mapTable- Table for the mapmapStore- Backing store for the Map using join tableclr- ClassLoader resolver
-
MapEntrySetStore
MapEntrySetStore(DatastoreClass mapTable, FKMapStore<K, V> mapStore, org.datanucleus.ClassLoaderResolver clr) Constructor for a store of the entries in a map when represented by either the key table or value table.- Parameters:
mapTable- The table storing the map relation (key table or value table)mapStore- The backing store for the FK map itselfclr- ClassLoader resolver
-
-
Method Details
-
hasOrderMapping
public boolean hasOrderMapping()- Specified by:
hasOrderMappingin interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
-
getMapStore
-
getOwnerMapping
- Overrides:
getOwnerMappingin classBaseContainerStore
-
getKeyMapping
-
getValueMapping
-
updateEmbeddedElement
public boolean updateEmbeddedElement(org.datanucleus.state.DNStateManager sm, Map.Entry<K, V> element, int fieldNumber, Object value) Method to update an embedded element.- Specified by:
updateEmbeddedElementin interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>- Parameters:
sm- StateManager of the ownerelement- The element to updatefieldNumber- The number of the field to updatevalue- The value- Returns:
- Whether the element was modified
-
validateElementType
-
update
Method to update the collection to be the supplied collection of elements.- Specified by:
updatein interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>- Parameters:
sm- StateManager of the objectcoll- The collection to use
-
contains
-
add
-
addAll
- Specified by:
addAllin interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
-
remove
public boolean remove(org.datanucleus.state.DNStateManager sm, Object element, int size, boolean allowDependentField) Method to remove an entry from the Map.- Specified by:
removein interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>- Parameters:
sm- StateManager for the ownerelement- Entry to remove- Returns:
- Whether it was removed
-
removeAll
Method to remove entries from the Map.- Specified by:
removeAllin interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>- Parameters:
sm- StateManager for the ownerelements- Entries to remove- Returns:
- Whether they were removed
-
clear
public void clear(org.datanucleus.state.DNStateManager sm) Method to clear the Map.- Specified by:
clearin interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>- Parameters:
sm- StateManager for the owner.
-
size
public int size(org.datanucleus.state.DNStateManager sm) - Specified by:
sizein interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
-
getSizeStmt
Method to return a size statement.SELECT COUNT(*) FROM MAP_TABLE WHERE OWNER=? AND KEY IS NOT NULL
- Returns:
- The size statement
-
iterator
Method returning an iterator across the entries in the map for this owner object.- Specified by:
iteratorin interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>- Parameters:
ownerSM- StateManager of the owning object- Returns:
- The iterator for the entries (
map.entrySet().iterator()
).
-
getSQLStatementForIterator
protected SelectStatement getSQLStatementForIterator(org.datanucleus.state.DNStateManager ownerSM, org.datanucleus.FetchPlan fp, boolean addRestrictionOnOwner) Method to generate a SelectStatement for iterating through entries of the map. Creates a statement that selects the table holding the map definition (key/value mappings). Adds a restriction on the ownerMapping of the containerTable so we can restrict to the owner object. Adds a restriction on the keyMapping not being null.SELECT KEY, VALUE FROM MAP_TABLE WHERE OWNER_ID=? AND KEY IS NOT NULL
- Parameters:
ownerSM- StateManager for the owner objectfp- Fetch Plan to observe when selecting key/valueaddRestrictionOnOwner- Whether to add a restriction on the owner object for this map- Returns:
- The SelectStatement TODO Change this to return KeyValueIteratorStatement
-