org.datanucleus.store.rdbms.scostore
Class RDBMSJoinMapStore

java.lang.Object
  extended by org.datanucleus.store.rdbms.scostore.BaseContainerStore
      extended by org.datanucleus.store.rdbms.scostore.AbstractMapStore
          extended by org.datanucleus.store.rdbms.scostore.RDBMSJoinMapStore
All Implemented Interfaces:
org.datanucleus.store.scostore.MapStore, org.datanucleus.store.scostore.Store

public class RDBMSJoinMapStore
extends AbstractMapStore

RDBMS-specific implementation of an MapStore using join table.


Field Summary
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping adapterMapping
          when the element mappings columns can't be part of the primary key by datastore limitations like BLOB types.
protected  org.datanucleus.ClassLoaderResolver clr
           
 
Fields inherited from class org.datanucleus.store.rdbms.scostore.AbstractMapStore
iterateUsingDiscriminator, keyMapping, keysAreEmbedded, keysAreSerialised, keyType, kmd, mapTable, valueMapping, valuesAreEmbedded, valuesAreSerialised, valueTable, valueType, vmd
 
Fields inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowNulls, dba, LOCALISER, ownerMapping, ownerMemberMetaData, relationType, storeMgr
 
Constructor Summary
RDBMSJoinMapStore(MapTable mapTable, org.datanucleus.ClassLoaderResolver clr)
          Constructor for the backing store of a join map for RDBMS.
 
Method Summary
 void clear(org.datanucleus.store.ObjectProvider ownerSM)
          Method to clear the map of all values.
protected  void clearInternal(org.datanucleus.store.ObjectProvider ownerSM)
           
 org.datanucleus.store.scostore.SetStore entrySetStore()
          Accessor for the map entries in the Map.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getAdapterMapping()
           
protected  SQLStatement getSQLStatementForGet(org.datanucleus.store.ObjectProvider ownerSM)
          Method to return an SQLStatement for retrieving the value for a key.
protected  Object getValue(org.datanucleus.store.ObjectProvider ownerSM, Object key)
          Method to retrieve a value from the Map given the key.
protected  int[] internalPut(org.datanucleus.store.ObjectProvider ownerSM, org.datanucleus.store.connection.ManagedConnection conn, boolean batched, Object key, Object value, boolean executeNow)
          Method to process a "put" statement (where the key has no value in the join table).
protected  void internalUpdate(org.datanucleus.store.ObjectProvider ownerSM, org.datanucleus.store.connection.ManagedConnection conn, boolean batched, Object key, Object value, boolean executeNow)
          Method to process an "update" statement (where the key already has a value in the join table).
 org.datanucleus.store.scostore.SetStore keySetStore()
          Accessor for the keys in the Map.
protected  org.datanucleus.store.scostore.SetStore newMapEntrySetStore()
           
protected  org.datanucleus.store.scostore.SetStore newMapKeySetStore()
           
protected  org.datanucleus.store.scostore.SetStore newMapValueSetStore()
           
 Object put(org.datanucleus.store.ObjectProvider sm, Object key, Object value)
          Method to put an item in the Map.
 void putAll(org.datanucleus.store.ObjectProvider sm, Map m)
          Method to put all elements from a Map into our Map.
 Object remove(org.datanucleus.store.ObjectProvider sm, Object key)
          Method to remove an item from the map.
protected  void removeInternal(org.datanucleus.store.ObjectProvider sm, Object key)
           
 org.datanucleus.store.scostore.SetStore valueSetStore()
          Accessor for the values in the Map.
 
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractMapStore
containsKey, containsValue, get, getKeyMapping, getKmd, getMapTable, getUpdateEmbeddedKeyStmt, getUpdateEmbeddedValueStmt, getValueMapping, getVmd, initialise, isValuesAreEmbedded, isValuesAreSerialised, keysAreEmbedded, keysAreSerialised, updatedEmbeddedKey, updateEmbeddedKey, updateEmbeddedValue, updateEmbeddedValue, validateKeyForReading, validateKeyForWriting, validateKeyType, validateValueForReading, validateValueForWriting, validateValueType, valuesAreEmbedded, valuesAreSerialised
 
Methods inherited from class org.datanucleus.store.rdbms.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 org.datanucleus.store.mapped.mapping.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 org.datanucleus.ClassLoaderResolver clr
Constructor Detail

RDBMSJoinMapStore

public RDBMSJoinMapStore(MapTable mapTable,
                         org.datanucleus.ClassLoaderResolver clr)
Constructor for the backing store of a join map for RDBMS.

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

putAll

public void putAll(org.datanucleus.store.ObjectProvider sm,
                   Map m)
Method to put all elements from a Map into our Map.

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

put

public Object put(org.datanucleus.store.ObjectProvider sm,
                  Object key,
                  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 Object remove(org.datanucleus.store.ObjectProvider sm,
                     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.

clear

public void clear(org.datanucleus.store.ObjectProvider ownerSM)
Method to clear the map of all values.

Parameters:
ownerSM - State Manager for the map.

keySetStore

public org.datanucleus.store.scostore.SetStore keySetStore()
Accessor for the keys in the Map.

Returns:
The keys

valueSetStore

public org.datanucleus.store.scostore.SetStore valueSetStore()
Accessor for the values in the Map.

Returns:
The values.

entrySetStore

public org.datanucleus.store.scostore.SetStore entrySetStore()
Accessor for the map entries in the Map.

Returns:
The map entries.

getAdapterMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getAdapterMapping()

getValue

protected Object getValue(org.datanucleus.store.ObjectProvider ownerSM,
                          Object key)
                   throws NoSuchElementException
Method to retrieve a value from the Map given the key.

Specified by:
getValue in class AbstractMapStore
Parameters:
ownerSM - State Manager for the owner of the map.
key - The key to retrieve the value for.
Returns:
The value for this key
Throws:
NoSuchElementException - if the value for the key was not found

getSQLStatementForGet

protected SQLStatement getSQLStatementForGet(org.datanucleus.store.ObjectProvider ownerSM)
Method to return an SQLStatement for retrieving the value for a key. Selects the join table and optionally joins to the value table if it has its own table.

Parameters:
ownerSM - StateManager for the owning object
Returns:
The SQLStatement

clearInternal

protected void clearInternal(org.datanucleus.store.ObjectProvider ownerSM)

removeInternal

protected void removeInternal(org.datanucleus.store.ObjectProvider sm,
                              Object key)

newMapKeySetStore

protected org.datanucleus.store.scostore.SetStore newMapKeySetStore()

newMapValueSetStore

protected org.datanucleus.store.scostore.SetStore newMapValueSetStore()

newMapEntrySetStore

protected org.datanucleus.store.scostore.SetStore newMapEntrySetStore()

internalUpdate

protected void internalUpdate(org.datanucleus.store.ObjectProvider ownerSM,
                              org.datanucleus.store.connection.ManagedConnection conn,
                              boolean batched,
                              Object key,
                              Object value,
                              boolean executeNow)
                       throws org.datanucleus.store.mapped.exceptions.MappedDatastoreException
Method to process an "update" statement (where the key already has a value in the join table).

Parameters:
ownerSM - StateManager for the owner
conn - The Connection
batched - Whether we are batching it
key - The key
value - The new value
executeNow - Whether to execute the statement now or wait til any batch
Throws:
org.datanucleus.store.mapped.exceptions.MappedDatastoreException - Thrown if an error occurs

internalPut

protected int[] internalPut(org.datanucleus.store.ObjectProvider ownerSM,
                            org.datanucleus.store.connection.ManagedConnection conn,
                            boolean batched,
                            Object key,
                            Object value,
                            boolean executeNow)
                     throws org.datanucleus.store.mapped.exceptions.MappedDatastoreException
Method to process a "put" statement (where the key has no value in the join table).

Parameters:
ownerSM - StateManager for the owner
conn - The Connection
batched - Whether we are batching it
key - The key
value - The value
executeNow - Whether to execute the statement now or wait til batching
Returns:
The return codes from any executed statement
Throws:
org.datanucleus.store.mapped.exceptions.MappedDatastoreException - Thrown if an error occurs


Copyright © 2012. All Rights Reserved.