org.datanucleus.store.rdbms.scostore
Class RDBMSFKMapStore

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.RDBMSFKMapStore
All Implemented Interfaces:
org.datanucleus.store.scostore.MapStore, org.datanucleus.store.scostore.Store

public class RDBMSFKMapStore
extends AbstractMapStore

RDBMS-specific implementation of an MapStore where either the value has a FK to the owner (and the key stored in the value), or whether the key has a FK to the owner (and the value stored in the key).


Field Summary
protected  org.datanucleus.ClassLoaderResolver clr
           
protected  int keyFieldNumber
          Field number of key in value class (when Key=Non-PC, Value=PC).
 
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
RDBMSFKMapStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)
          Constructor for the backing store for an FK Map for RDBMS.
 
Method Summary
 void clear(org.datanucleus.store.ObjectProvider sm)
          Method to clear the map of all values.
 void clearKeyOfValue(org.datanucleus.store.ObjectProvider sm, Object key, Object oldValue)
          Utility to clear the key of a value from the Map.
 org.datanucleus.store.scostore.SetStore entrySetStore()
          Accessor for the map entries in the Map.
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  void initialise()
          Method to initialise the statements being used.
 org.datanucleus.store.scostore.SetStore keySetStore()
          Accessor for the keys in the Map.
 Object put(org.datanucleus.store.ObjectProvider sm, Object newKey, Object newValue)
          Method to put an item in the Map.
 Object remove(org.datanucleus.store.ObjectProvider sm, Object key)
          Method to remove an entry from the map.
protected  boolean updateKeyFkInternal(org.datanucleus.store.ObjectProvider sm, Object key, Object owner)
           
protected  boolean updateValueFkInternal(org.datanucleus.store.ObjectProvider sm, Object value, Object owner)
           
protected  void validateValueType(org.datanucleus.ClassLoaderResolver clr, Object value)
          Utility to validate the type of a value for storing in the Map.
 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, isValuesAreEmbedded, isValuesAreSerialised, keysAreEmbedded, keysAreSerialised, putAll, updatedEmbeddedKey, updateEmbeddedKey, updateEmbeddedValue, updateEmbeddedValue, validateKeyForReading, validateKeyForWriting, validateKeyType, validateValueForReading, validateValueForWriting, 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

clr

protected final org.datanucleus.ClassLoaderResolver clr

keyFieldNumber

protected int keyFieldNumber
Field number of key in value class (when Key=Non-PC, Value=PC).

Constructor Detail

RDBMSFKMapStore

public RDBMSFKMapStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                       RDBMSStoreManager storeMgr,
                       org.datanucleus.ClassLoaderResolver clr)
Constructor for the backing store for an FK Map for RDBMS.

Parameters:
mmd - Field Meta-Data for the Map field.
storeMgr - The Store Manager we are using.
clr - The ClassLoaderResolver
Method Detail

initialise

protected void initialise()
Description copied from class: AbstractMapStore
Method to initialise the statements being used. Subclasses should override the getXXXStmt() if they want to use an alternative statement.

Overrides:
initialise in class AbstractMapStore

validateValueType

protected void validateValueType(org.datanucleus.ClassLoaderResolver clr,
                                 Object value)
Utility to validate the type of a value for storing in the Map.

Overrides:
validateValueType in class AbstractMapStore
Parameters:
value - The value to check.
clr - The ClassLoaderResolver

put

public Object put(org.datanucleus.store.ObjectProvider sm,
                  Object newKey,
                  Object newValue)
Method to put an item in the Map.

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

remove

public Object remove(org.datanucleus.store.ObjectProvider sm,
                     Object key)
Method to remove an entry from the map.

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

clear

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

Parameters:
sm - State Manager for the map.

clearKeyOfValue

public void clearKeyOfValue(org.datanucleus.store.ObjectProvider sm,
                            Object key,
                            Object oldValue)
Utility to clear the key of a value from the Map. If the key is non nullable, delete the value.

Parameters:
sm - State Manager for the map.
key - Key of the object
oldValue - Value to remove

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.

updateValueFkInternal

protected boolean updateValueFkInternal(org.datanucleus.store.ObjectProvider sm,
                                        Object value,
                                        Object owner)

updateKeyFkInternal

protected boolean updateKeyFkInternal(org.datanucleus.store.ObjectProvider sm,
                                      Object key,
                                      Object owner)

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 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


Copyright © 2012. All Rights Reserved.