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 class
Inner class representing the entry in the map.static class
Inner class representing an iterator for the Set. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]
private StatementParameterMapping
private String
SQL statement to use for retrieving data from the map (locking).private String
SQL statement to use for retrieving data from the map (normal).private int[]
protected JavaTypeMapping
Mapping for the key.The backing store for the Map.protected Table
Table containing the key and value forming the entry.private String
protected JavaTypeMapping
Mapping for the value.Fields inherited from class org.datanucleus.store.rdbms.scostore.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 TypeMethodDescriptionboolean
boolean
addAll
(org.datanucleus.state.DNStateManager sm, Collection entries, int size) void
clear
(org.datanucleus.state.DNStateManager sm) Method to clear the Map.boolean
private String
Method to return a size statement.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.boolean
iterator
(org.datanucleus.state.DNStateManager ownerSM) Method returning an iterator across the entries in the map for this owner object.boolean
remove
(org.datanucleus.state.DNStateManager sm, Object element, int size, boolean allowDependentField) Method to remove an entry from the Map.boolean
removeAll
(org.datanucleus.state.DNStateManager sm, Collection elements, int size) Method to remove entries from the Map.int
size
(org.datanucleus.state.DNStateManager sm) void
update
(org.datanucleus.state.DNStateManager sm, Collection coll) Method to update the collection to be the supplied collection of elements.boolean
updateEmbeddedElement
(org.datanucleus.state.DNStateManager sm, Map.Entry<K, V> element, int fieldNumber, Object value) Method to update an embedded element.protected boolean
validateElementType
(Object element) Methods inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowsBatching, getComponentInformationForClass, getDatastoreAdapter, 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.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
The backing store for the Map. -
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:
hasOrderMapping
in interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
-
getMapStore
-
getOwnerMapping
- Overrides:
getOwnerMapping
in 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:
updateEmbeddedElement
in 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:
update
in interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
- Parameters:
sm
- StateManager of the objectcoll
- The collection to use
-
contains
- Specified by:
contains
in interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
-
add
- Specified by:
add
in interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
-
addAll
- Specified by:
addAll
in 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:
remove
in 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:
removeAll
in 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:
clear
in interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
- Parameters:
sm
- StateManager for the owner.
-
size
public int size(org.datanucleus.state.DNStateManager sm) - Specified by:
size
in 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:
iterator
in 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
-