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<java.util.Map.Entry<K,V>>,org.datanucleus.store.types.scostore.SetStore<java.util.Map.Entry<K,V>>,org.datanucleus.store.types.scostore.Store
class MapEntrySetStore<K,V> extends BaseContainerStore implements org.datanucleus.store.types.scostore.SetStore<java.util.Map.Entry<K,V>>
RDBMS-specific implementation of a SetStore for map entries.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classMapEntrySetStore.EntryImpl<K,V>Inner class representing the entry in the map.static classMapEntrySetStore.SetIteratorInner class representing an iterator for the Set.
-
Field Summary
Fields Modifier and Type Field Description private int[]iteratorKeyResultColsprivate StatementParameterMappingiteratorMappingParamsprivate java.lang.StringiteratorSelectStmtLockedSqlSQL statement to use for retrieving data from the map (locking).private java.lang.StringiteratorSelectStmtSqlSQL statement to use for retrieving data from the map (normal).private int[]iteratorValueResultColsprotected JavaTypeMappingkeyMappingMapping for the key.protected org.datanucleus.store.types.scostore.MapStore<K,V>mapStoreThe backing store for the Map.protected TablemapTableTable containing the key and value forming the entry.private java.lang.StringsizeStmtprotected JavaTypeMappingvalueMappingMapping for the value.-
Fields inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowNulls, clr, dba, ownerMapping, ownerMemberMetaData, relationType, storeMgr
-
-
Constructor Summary
Constructors Constructor Description 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.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(org.datanucleus.state.DNStateManager sm, java.util.Map.Entry<K,V> entry, int size)booleanaddAll(org.datanucleus.state.DNStateManager sm, java.util.Collection entries, int size)voidclear(org.datanucleus.state.DNStateManager sm)Method to clear the Map.booleancontains(org.datanucleus.state.DNStateManager sm, java.lang.Object element)JavaTypeMappinggetKeyMapping()org.datanucleus.store.types.scostore.MapStore<K,V>getMapStore()JavaTypeMappinggetOwnerMapping()private java.lang.StringgetSizeStmt()Method 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.JavaTypeMappinggetValueMapping()booleanhasOrderMapping()java.util.Iterator<java.util.Map.Entry<K,V>>iterator(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, java.lang.Object element, int size, boolean allowDependentField)Method to remove an entry from the Map.booleanremoveAll(org.datanucleus.state.DNStateManager sm, java.util.Collection elements, int size)Method to remove entries from the Map.intsize(org.datanucleus.state.DNStateManager sm)voidupdate(org.datanucleus.state.DNStateManager sm, java.util.Collection coll)Method to update the collection to be the supplied collection of elements.booleanupdateEmbeddedElement(org.datanucleus.state.DNStateManager sm, java.util.Map.Entry<K,V> element, int fieldNumber, java.lang.Object value)Method to update an embedded element.protected booleanvalidateElementType(java.lang.Object element)-
Methods inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowsBatching, getComponentInformationForClass, getDatastoreAdapter, getOwnerMemberMetaData, getRelationType, getStateManagerForEmbeddedPCObject, getStoreManager, isEmbeddedMapping, setOwner
-
-
-
-
Field Detail
-
mapTable
protected Table 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
protected org.datanucleus.store.types.scostore.MapStore<K,V> mapStore
The backing store for the Map.
-
keyMapping
protected JavaTypeMapping keyMapping
Mapping for the key.
-
valueMapping
protected JavaTypeMapping valueMapping
Mapping for the value.
-
sizeStmt
private java.lang.String sizeStmt
-
iteratorSelectStmtSql
private java.lang.String iteratorSelectStmtSql
SQL statement to use for retrieving data from the map (normal).
-
iteratorSelectStmtLockedSql
private java.lang.String iteratorSelectStmtLockedSql
SQL statement to use for retrieving data from the map (locking).
-
iteratorKeyResultCols
private int[] iteratorKeyResultCols
-
iteratorValueResultCols
private int[] iteratorValueResultCols
-
iteratorMappingParams
private StatementParameterMapping iteratorMappingParams
-
-
Constructor Detail
-
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 Detail
-
hasOrderMapping
public boolean hasOrderMapping()
- Specified by:
hasOrderMappingin interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
-
getOwnerMapping
public JavaTypeMapping getOwnerMapping()
- Overrides:
getOwnerMappingin classBaseContainerStore
-
getKeyMapping
public JavaTypeMapping getKeyMapping()
-
getValueMapping
public JavaTypeMapping getValueMapping()
-
updateEmbeddedElement
public boolean updateEmbeddedElement(org.datanucleus.state.DNStateManager sm, java.util.Map.Entry<K,V> element, int fieldNumber, java.lang.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
protected boolean validateElementType(java.lang.Object element)
-
update
public void update(org.datanucleus.state.DNStateManager sm, java.util.Collection coll)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
public boolean contains(org.datanucleus.state.DNStateManager sm, java.lang.Object element)- Specified by:
containsin interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
-
add
public boolean add(org.datanucleus.state.DNStateManager sm, java.util.Map.Entry<K,V> entry, int size)- Specified by:
addin interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
-
addAll
public boolean addAll(org.datanucleus.state.DNStateManager sm, java.util.Collection entries, int size)- Specified by:
addAllin interfaceorg.datanucleus.store.types.scostore.CollectionStore<K>
-
remove
public boolean remove(org.datanucleus.state.DNStateManager sm, java.lang.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
public boolean removeAll(org.datanucleus.state.DNStateManager sm, java.util.Collection elements, int size)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
private java.lang.String getSizeStmt()
Method to return a size statement.SELECT COUNT(*) FROM MAP_TABLE WHERE OWNER=? AND KEY IS NOT NULL
- Returns:
- The size statement
-
iterator
public java.util.Iterator<java.util.Map.Entry<K,V>> iterator(org.datanucleus.state.DNStateManager ownerSM)
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
-
-