Class MapValueCollectionStore<V>
- java.lang.Object
-
- org.datanucleus.store.rdbms.scostore.BaseContainerStore
-
- org.datanucleus.store.rdbms.scostore.ElementContainerStore
-
- org.datanucleus.store.rdbms.scostore.AbstractCollectionStore<V>
-
- org.datanucleus.store.rdbms.scostore.MapValueCollectionStore<V>
-
- All Implemented Interfaces:
org.datanucleus.store.types.scostore.CollectionStore<V>
,org.datanucleus.store.types.scostore.Store
class MapValueCollectionStore<V> extends AbstractCollectionStore<V>
RDBMS-specific implementation of a CollectionStore for map values.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
findKeyStmt
private StatementClassMapping
iteratorMappingDef
private StatementParameterMapping
iteratorMappingParams
private java.lang.String
iteratorStmtLocked
JDBC statement to use for retrieving keys of the map (locking).private java.lang.String
iteratorStmtUnlocked
JDBC statement to use for retrieving keys of the map (not locking).protected JavaTypeMapping
keyMapping
protected org.datanucleus.store.types.scostore.MapStore<?,V>
mapStore
-
Fields inherited from class org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
containsStmt
-
Fields inherited from class org.datanucleus.store.rdbms.scostore.ElementContainerStore
addStmt, clearStmt, containerTable, elementCmd, elementInfo, elementIsPersistentInterface, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, iterateUsingDiscriminator, orderMapping, relationDiscriminatorMapping, relationDiscriminatorValue, removeStmt, sizeStmt
-
Fields inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowNulls, clr, dba, ownerMapping, ownerMemberMetaData, relationType, storeMgr
-
-
Constructor Summary
Constructors Constructor Description MapValueCollectionStore(DatastoreClass mapTable, FKMapStore<?,V> mapStore, org.datanucleus.ClassLoaderResolver clr)
Constructor when we have the key stored as an FK in the value, or the value stored as an FK in the key.MapValueCollectionStore(MapTable mapTable, JoinMapStore<?,V> mapStore, org.datanucleus.ClassLoaderResolver clr)
Constructor where a join table is used to store the map relation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(org.datanucleus.state.DNStateManager sm, V value, int size)
boolean
addAll(org.datanucleus.state.DNStateManager sm, java.util.Collection<? extends V> values, int size)
void
clear(org.datanucleus.state.DNStateManager sm)
Clear the association from owner to all elements.private java.lang.String
getFindKeyStmt()
Generate statement to find the first key for a value in the Map.protected SelectStatement
getSQLStatementForIterator(org.datanucleus.state.DNStateManager ownerSM)
Method to generate an SQLStatement for iterating through values of the map.private void
initialize(org.datanucleus.ClassLoaderResolver clr)
Initialise Method.java.util.Iterator<V>
iterator(org.datanucleus.state.DNStateManager ownerSM)
Accessor for an iterator for the set.protected boolean
remove(org.datanucleus.state.DNStateManager sm, java.lang.Object value)
boolean
remove(org.datanucleus.state.DNStateManager sm, java.lang.Object value, int size, boolean allowDependentField)
boolean
removeAll(org.datanucleus.state.DNStateManager sm, java.util.Collection values, int size)
-
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
contains, getRemoveStmt, getUpdateEmbeddedElementStmt, update, updateEmbeddedElement
-
Methods inherited from class org.datanucleus.store.rdbms.scostore.ElementContainerStore
getAddStmtForJoinTable, getClearStmt, getComponentInfoForElement, getContainerTable, getElementClassMetaData, getElementMapping, getRelationDiscriminatorMapping, getRelationDiscriminatorValue, getSize, getSizeStmt, hasOrderMapping, invalidateAddStmt, isElementsAreEmbedded, isElementsAreSerialised, size, usingJoinTable, validateElementForReading, validateElementForWriting, validateElementType
-
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
-
-
-
-
Field Detail
-
mapStore
protected final org.datanucleus.store.types.scostore.MapStore<?,V> mapStore
-
keyMapping
protected final JavaTypeMapping keyMapping
-
findKeyStmt
private java.lang.String findKeyStmt
-
iteratorStmtLocked
private java.lang.String iteratorStmtLocked
JDBC statement to use for retrieving keys of the map (locking).
-
iteratorStmtUnlocked
private java.lang.String iteratorStmtUnlocked
JDBC statement to use for retrieving keys of the map (not locking).
-
iteratorMappingDef
private StatementClassMapping iteratorMappingDef
-
iteratorMappingParams
private StatementParameterMapping iteratorMappingParams
-
-
Constructor Detail
-
MapValueCollectionStore
MapValueCollectionStore(MapTable mapTable, JoinMapStore<?,V> mapStore, org.datanucleus.ClassLoaderResolver clr)
Constructor where a join table is used to store the map relation.- Parameters:
mapTable
- Join table used by the mapmapStore
- Backing store for the mapclr
- The ClassLoaderResolver
-
MapValueCollectionStore
MapValueCollectionStore(DatastoreClass mapTable, FKMapStore<?,V> mapStore, org.datanucleus.ClassLoaderResolver clr)
Constructor when we have the key stored as an FK in the value, or the value stored as an FK in the key.- Parameters:
mapTable
- Table handling the map relation (can be key table or value table)mapStore
- Backing store for the mapclr
- ClassLoader resolver
-
-
Method Detail
-
initialize
private void initialize(org.datanucleus.ClassLoaderResolver clr)
Initialise Method.- Parameters:
clr
- ClassLoader resolver
-
add
public boolean add(org.datanucleus.state.DNStateManager sm, V value, int size)
-
addAll
public boolean addAll(org.datanucleus.state.DNStateManager sm, java.util.Collection<? extends V> values, int size)
-
remove
public boolean remove(org.datanucleus.state.DNStateManager sm, java.lang.Object value, int size, boolean allowDependentField)
-
removeAll
public boolean removeAll(org.datanucleus.state.DNStateManager sm, java.util.Collection values, int size)
-
clear
public void clear(org.datanucleus.state.DNStateManager sm)
Description copied from class:ElementContainerStore
Clear the association from owner to all elements. Provides cascade-delete when the elements being deleted are PC types.- Specified by:
clear
in interfaceorg.datanucleus.store.types.scostore.CollectionStore<V>
- Overrides:
clear
in classElementContainerStore
- Parameters:
sm
- StateManager for the container.
-
remove
protected boolean remove(org.datanucleus.state.DNStateManager sm, java.lang.Object value)
-
getFindKeyStmt
private java.lang.String getFindKeyStmt()
Generate statement to find the first key for a value in the Map.SELECT KEYCOL FROM SETTABLE WHERE OWNERCOL=? AND ELEMENTCOL = ?
- Returns:
- Statement to find keys in the Map.
-
iterator
public java.util.Iterator<V> iterator(org.datanucleus.state.DNStateManager ownerSM)
Accessor for an iterator for the set.- Specified by:
iterator
in interfaceorg.datanucleus.store.types.scostore.CollectionStore<V>
- Specified by:
iterator
in classElementContainerStore
- Parameters:
ownerSM
- StateManager for the set.- Returns:
- Iterator for the set.
-
getSQLStatementForIterator
protected SelectStatement getSQLStatementForIterator(org.datanucleus.state.DNStateManager ownerSM)
Method to generate an SQLStatement for iterating through values of the map. Populates the iteratorMappingDef and iteratorMappingParams. Creates a statement that selects the value table(s), and adds any necessary join to the containerTable if that is not the value table. If the value is embedded then selects the table it is embedded in. Adds a restriction on the ownerMapping of the containerTable so we can restrict to the owner object.- Parameters:
ownerSM
- StateManager for the owner object- Returns:
- The SQLStatement
-
-