org.datanucleus.store.mapped.scostore
Class JoinMapStore

java.lang.Object
  extended by org.datanucleus.store.mapped.scostore.BaseContainerStore
      extended by org.datanucleus.store.mapped.scostore.AbstractMapStore
          extended by org.datanucleus.store.mapped.scostore.JoinMapStore
All Implemented Interfaces:
MapStoreQueryable, MapStore, Store

public abstract class JoinMapStore
extends AbstractMapStore

Representation of the backing store for a Map. Uses a join table to link the owning container object with the values/keys contained in the map.


Field Summary
protected  JavaTypeMapping adapterMapping
          when the element mappings columns can't be part of the primary key by datastore limitations like BLOB types.
protected  ClassLoaderResolver clr
           
 
Fields inherited from class org.datanucleus.store.mapped.scostore.AbstractMapStore
iterateUsingDiscriminator, keyMapping, keysAreEmbedded, keysAreSerialised, keyType, kmd, mapTable, specialization, valueMapping, valuesAreEmbedded, valuesAreSerialised, valueTable, valueType, vmd
 
Fields inherited from class org.datanucleus.store.mapped.scostore.BaseContainerStore
allowsNull, dba, LOCALISER, ownerMapping, ownerMemberMetaData, relationType, storeMgr
 
Constructor Summary
JoinMapStore(DatastoreContainerObject mapTable, ClassLoaderResolver clr, JavaTypeMapping ownerMapping, JavaTypeMapping keyMapping, JavaTypeMapping valueMapping, JavaTypeMapping orderMapping, java.lang.String keyType, boolean isEmbeddedKey, boolean isSerialisedKey, java.lang.String valueType, boolean isEmbeddedValue, boolean isSerialisedValue, AbstractMemberMetaData ownerMemberMetaData, AbstractMapStoreSpecialization specialization)
          Constructor for an Inverse Map.
 
Method Summary
 void clear(StateManager ownerSM)
          Method to clear the map of all values.
protected abstract  void clearInternal(StateManager ownerSM)
           
 SetStore entrySetStore()
          Accessor for the map entries in the Map.
 JavaTypeMapping getAdapterMapping()
           
protected abstract  int[] internalPut(StateManager ownerSM, ManagedConnection conn, boolean batched, java.lang.Object key, java.lang.Object value, boolean executeNow)
           
protected abstract  void internalUpdate(StateManager ownerSM, ManagedConnection conn, boolean batched, java.lang.Object key, java.lang.Object value, boolean executeNow)
           
 ScalarExpression joinKeysTo(QueryExpression stmt, QueryExpression parentStmt, JavaTypeMapping ownerMapping, LogicSetExpression ownerTe, DatastoreIdentifier mapTableAlias, java.lang.Class filteredKeyType, ScalarExpression keyExpr, DatastoreIdentifier keyTableAlias)
          Utility to create a join for keys to be used in a containsKey() query.
 ScalarExpression[] joinKeysValuesTo(QueryExpression stmt, QueryExpression parentStmt, JavaTypeMapping ownerMapping, LogicSetExpression ownerTe, DatastoreIdentifier mapTableAlias, java.lang.Class filteredKeyType, java.lang.Class filteredValueType, ScalarExpression keyExpr, ScalarExpression valExpr, DatastoreIdentifier keyTableAlias, DatastoreIdentifier valueTableAlias)
          Utility to create a join for keys and values to be used in a containsEntry() query.
 ScalarExpression joinValuesTo(QueryExpression stmt, QueryExpression parentStmt, JavaTypeMapping ownerMapping, LogicSetExpression ownerTe, DatastoreIdentifier mapTableAlias, java.lang.Class filteredValueType, ScalarExpression valExpr, DatastoreIdentifier valueTableAlias)
          Used as part of the Querying of Maps where a containsValue() is used.
 SetStore keySetStore()
          Accessor for the keys in the Map.
protected abstract  MapEntrySetStore newMapEntrySetStore()
           
protected abstract  MapKeySetStore newMapKeySetStore()
           
protected abstract  MapValueSetStore newMapValueSetStore()
           
 java.lang.Object put(StateManager sm, java.lang.Object key, java.lang.Object value)
          Method to put an item in the Map.
 void putAll(StateManager sm, java.util.Map m)
          Method to put all elements from a Map into our Map.
 java.lang.Object remove(StateManager sm, java.lang.Object key)
          Method to remove an item from the map.
protected abstract  void removeInternal(StateManager sm, java.lang.Object key)
           
 SetStore valueSetStore()
          Accessor for the values in the Map.
 
Methods inherited from class org.datanucleus.store.mapped.scostore.AbstractMapStore
containsKey, containsValue, get, getExistsSubquery, getKeyMapping, getKeyType, getKmd, getMapTable, getSizeSubquery, getValue, getValueMapping, getValueType, getVmd, isValuesAreEmbedded, isValuesAreSerialised, joinKeysToGet, keysAreEmbedded, keysAreSerialised, updateEmbeddedKey, updateEmbeddedValue, validateKeyForReading, validateKeyForWriting, validateKeyType, validateValueForReading, validateValueForWriting, validateValueType, valuesAreEmbedded, valuesAreSerialised
 
Methods inherited from class org.datanucleus.store.mapped.scostore.BaseContainerStore
allowsBatching, 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.scostore.Store
getStoreManager
 

Field Detail

adapterMapping

protected final JavaTypeMapping adapterMapping
when the element mappings columns can't be part of the primary key by datastore limitations like BLOB types. An adapter mapping is used to be a kind of "index"


clr

protected ClassLoaderResolver clr
Constructor Detail

JoinMapStore

public JoinMapStore(DatastoreContainerObject mapTable,
                    ClassLoaderResolver clr,
                    JavaTypeMapping ownerMapping,
                    JavaTypeMapping keyMapping,
                    JavaTypeMapping valueMapping,
                    JavaTypeMapping orderMapping,
                    java.lang.String keyType,
                    boolean isEmbeddedKey,
                    boolean isSerialisedKey,
                    java.lang.String valueType,
                    boolean isEmbeddedValue,
                    boolean isSerialisedValue,
                    AbstractMemberMetaData ownerMemberMetaData,
                    AbstractMapStoreSpecialization specialization)
Constructor for an Inverse Map.

Parameters:
mapTable - Join table for the Map
clr - The ClassLoaderResolver
specialization - The Specialization
Method Detail

putAll

public void putAll(StateManager sm,
                   java.util.Map m)
Method to put all elements from a Map into our Map.

Specified by:
putAll in interface MapStore
Overrides:
putAll in class AbstractMapStore
Parameters:
sm - State Manager for the Map
m - The Map to add

put

public java.lang.Object put(StateManager sm,
                            java.lang.Object key,
                            java.lang.Object value)
Method to put an item in the Map.

Parameters:
sm - State Manager for the map.
key - The key to store the value against
value - The value to store.
Returns:
The value stored.

remove

public java.lang.Object remove(StateManager sm,
                               java.lang.Object key)
Method to remove an item from the map.

Parameters:
sm - State Manager for the map.
key - Key of the item to remove.
Returns:
The value that was removed.

removeInternal

protected abstract void removeInternal(StateManager sm,
                                       java.lang.Object key)

clear

public void clear(StateManager ownerSM)
Method to clear the map of all values.

Parameters:
ownerSM - State Manager for the map.

clearInternal

protected abstract void clearInternal(StateManager ownerSM)

keySetStore

public SetStore keySetStore()
Accessor for the keys in the Map.

Returns:
The keys

valueSetStore

public SetStore valueSetStore()
Accessor for the values in the Map.

Returns:
The values.

entrySetStore

public SetStore entrySetStore()
Accessor for the map entries in the Map.

Returns:
The map entries.

getAdapterMapping

public JavaTypeMapping getAdapterMapping()

newMapKeySetStore

protected abstract MapKeySetStore newMapKeySetStore()

newMapValueSetStore

protected abstract MapValueSetStore newMapValueSetStore()

newMapEntrySetStore

protected abstract MapEntrySetStore newMapEntrySetStore()

internalUpdate

protected abstract void internalUpdate(StateManager ownerSM,
                                       ManagedConnection conn,
                                       boolean batched,
                                       java.lang.Object key,
                                       java.lang.Object value,
                                       boolean executeNow)
                                throws MappedDatastoreException
Throws:
MappedDatastoreException

internalPut

protected abstract int[] internalPut(StateManager ownerSM,
                                     ManagedConnection conn,
                                     boolean batched,
                                     java.lang.Object key,
                                     java.lang.Object value,
                                     boolean executeNow)
                              throws MappedDatastoreException
Throws:
MappedDatastoreException

joinKeysTo

public ScalarExpression joinKeysTo(QueryExpression stmt,
                                   QueryExpression parentStmt,
                                   JavaTypeMapping ownerMapping,
                                   LogicSetExpression ownerTe,
                                   DatastoreIdentifier mapTableAlias,
                                   java.lang.Class filteredKeyType,
                                   ScalarExpression keyExpr,
                                   DatastoreIdentifier keyTableAlias)
Utility to create a join for keys to be used in a containsKey() query.

Parameters:
stmt - The Query Statement
parentStmt - the parent Query Statement. If there is no parent, parentStmt must be equals to stmt
ownerMapping - Mapping for the owner
ownerTe - Table Expression for the owner
mapTableAlias - Alias for the "Map" table.
filteredKeyType - The Class Type for the filtered key
keyTableAlias - The SQL alias to assign to the expression or to the key table.
keyExpr - the expression to the key field. if not provided, obtain the expression of the ID of the table where filteredKeyType is stored
Returns:
QueryColumnList with the columns from the key mapping

joinKeysValuesTo

public ScalarExpression[] joinKeysValuesTo(QueryExpression stmt,
                                           QueryExpression parentStmt,
                                           JavaTypeMapping ownerMapping,
                                           LogicSetExpression ownerTe,
                                           DatastoreIdentifier mapTableAlias,
                                           java.lang.Class filteredKeyType,
                                           java.lang.Class filteredValueType,
                                           ScalarExpression keyExpr,
                                           ScalarExpression valExpr,
                                           DatastoreIdentifier keyTableAlias,
                                           DatastoreIdentifier valueTableAlias)
Utility to create a join for keys and values to be used in a containsEntry() query.

Parameters:
stmt - The Query Statement to apply the join
parentStmt - the parent Query Statement. If there is no parent, parentStmt must be equals to stmt
ownerMapping - Mapping for the owner
ownerTe - Table Expression for the owner
mapTableAlias - The SQL alias to assign to the expression or to the main table.
filteredKeyType - The Class Type for the filtered key
filteredValueType - The Class Type for the filtered value
keyExpr - the expression to the key field
valExpr - Table Expression for the value
keyTableAlias - The SQL alias to assign to the expression or to the key table.
valueTableAlias - The SQL alias to assign to the expression or to the value table.
Returns:
an array with 2 elements of QueryColumnList. The first element contains the columns from the key mapping and the second element the columns from the value mapping

joinValuesTo

public ScalarExpression joinValuesTo(QueryExpression stmt,
                                     QueryExpression parentStmt,
                                     JavaTypeMapping ownerMapping,
                                     LogicSetExpression ownerTe,
                                     DatastoreIdentifier mapTableAlias,
                                     java.lang.Class filteredValueType,
                                     ScalarExpression valExpr,
                                     DatastoreIdentifier valueTableAlias)
Used as part of the Querying of Maps where a containsValue() is used.

Parameters:
stmt - The Query Statement
parentStmt - the parent Query Statement. If there is no parent, parentStmt must be equals to stmt
ownerMapping - Mapping for the owner
ownerTe - Table Expression for the owner
mapTableAlias - Alias for the "Map" table.
filteredValueType - The Class Type for the filtered value
valExpr - the expression to the value field. if not provided, obtain the expression of the ID of the table where filteredValueType is stored
valueTableAlias - The SQL alias to assign to the expression or to the value table.
Returns:
QueryColumnList with the columns from the value mapping


Copyright © 2010. All Rights Reserved.