org.datanucleus.store.rdbms.scostore
Class AbstractMapStore

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

public abstract class AbstractMapStore
extends BaseContainerStore
implements org.datanucleus.store.scostore.MapStore

Abstract representation of the backing store for a Map.


Field Summary
protected  boolean iterateUsingDiscriminator
          Flag to set whether the iterator statement will use a discriminator or not.
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping keyMapping
          Mapping to the key from the mapTable.
protected  boolean keysAreEmbedded
          Whether the keys are embedded.
protected  boolean keysAreSerialised
          Whether the keys are serialised.
protected  String keyType
          Type of the key.
protected  org.datanucleus.metadata.AbstractClassMetaData kmd
          Metadata for the keys (if persistable).
protected  org.datanucleus.store.mapped.DatastoreContainerObject mapTable
          Table storing the map relation.
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping valueMapping
          Mapping to the value from the mapTable.
protected  boolean valuesAreEmbedded
          Whether the values are embedded.
protected  boolean valuesAreSerialised
          Whether the values are serialised.
protected  org.datanucleus.store.mapped.DatastoreClass valueTable
          Table storing the values.
protected  String valueType
          Type of the value.
protected  org.datanucleus.metadata.AbstractClassMetaData vmd
          Metadata for the values (if persistable).
 
Fields inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowNulls, dba, LOCALISER, ownerMapping, ownerMemberMetaData, relationType, storeMgr
 
Constructor Summary
AbstractMapStore(RDBMSStoreManager storeMgr)
          Constructor.
 
Method Summary
 boolean containsKey(org.datanucleus.store.ObjectProvider sm, Object key)
          Method to check if a key exists in the Map.
 boolean containsValue(org.datanucleus.store.ObjectProvider sm, Object value)
          Method to check if a value exists in the Map.
 Object get(org.datanucleus.store.ObjectProvider sm, Object key)
          Method to return the value for a key.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getKeyMapping()
           
 org.datanucleus.metadata.AbstractClassMetaData getKmd()
           
 org.datanucleus.store.mapped.DatastoreContainerObject getMapTable()
           
protected  String getUpdateEmbeddedKeyStmt(org.datanucleus.store.mapped.mapping.JavaTypeMapping fieldMapping, org.datanucleus.store.mapped.mapping.JavaTypeMapping ownerMapping, org.datanucleus.store.mapped.mapping.JavaTypeMapping keyMapping, org.datanucleus.store.mapped.DatastoreContainerObject mapTable)
          Generate statement for update the field of an embedded key.
protected  String getUpdateEmbeddedValueStmt(org.datanucleus.store.mapped.mapping.JavaTypeMapping fieldMapping, org.datanucleus.store.mapped.mapping.JavaTypeMapping ownerMapping, org.datanucleus.store.mapped.mapping.JavaTypeMapping valueMapping, org.datanucleus.store.mapped.DatastoreContainerObject mapTable)
          Generate statement for update the field of an embedded value.
protected abstract  Object getValue(org.datanucleus.store.ObjectProvider sm, Object key)
          Method to retrieve a value from the Map given the key.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getValueMapping()
           
 org.datanucleus.metadata.AbstractClassMetaData getVmd()
           
protected  void initialise()
          Method to initialise the statements being used.
 boolean isValuesAreEmbedded()
           
 boolean isValuesAreSerialised()
           
 boolean keysAreEmbedded()
          Accessor for whether the keys are embedded or not.
 boolean keysAreSerialised()
          Accessor for whether the keys are serialised or not.
 void putAll(org.datanucleus.store.ObjectProvider sm, Map m)
          Method to put all elements from a Map into our Map.
 boolean updatedEmbeddedKey(org.datanucleus.store.ObjectProvider sm, Object key, int fieldNumber, Object newValue, org.datanucleus.store.mapped.mapping.JavaTypeMapping fieldMapping)
           
 boolean updateEmbeddedKey(org.datanucleus.store.ObjectProvider sm, Object key, int fieldNumber, Object newValue)
          Method to update a field of an embedded key.
 boolean updateEmbeddedValue(org.datanucleus.store.ObjectProvider sm, Object value, int fieldNumber, Object newValue)
          Method to update a field of an embedded key.
 boolean updateEmbeddedValue(org.datanucleus.store.ObjectProvider sm, Object value, int fieldNumber, Object newValue, org.datanucleus.store.mapped.mapping.JavaTypeMapping fieldMapping)
           
protected  boolean validateKeyForReading(org.datanucleus.store.ObjectProvider sm, Object key)
          Utility to validate a key is ok for reading.
protected  void validateKeyForWriting(org.datanucleus.store.ObjectProvider ownerOP, Object key)
          Utility to validate a key is ok for writing (present in the datastore).
protected  void validateKeyType(org.datanucleus.ClassLoaderResolver clr, Object key)
          Utility to validate the type of a key for storing in the Map.
protected  boolean validateValueForReading(org.datanucleus.store.ObjectProvider sm, Object value)
          Utility to validate a value is ok for reading.
protected  void validateValueForWriting(org.datanucleus.store.ObjectProvider ownerOP, Object value)
          Utility to validate a value is ok for writing (present in the datastore).
protected  void validateValueType(org.datanucleus.ClassLoaderResolver clr, Object value)
          Utility to validate the type of a value for storing in the Map.
 boolean valuesAreEmbedded()
          Accessor for whether the values are embedded or not.
 boolean valuesAreSerialised()
          Accessor for whether the values are serialised or not.
 
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.MapStore
clear, entrySetStore, keySetStore, put, remove, valueSetStore
 
Methods inherited from interface org.datanucleus.store.scostore.Store
getStoreManager
 

Field Detail

iterateUsingDiscriminator

protected boolean iterateUsingDiscriminator
Flag to set whether the iterator statement will use a discriminator or not.


mapTable

protected org.datanucleus.store.mapped.DatastoreContainerObject mapTable
Table storing the map relation. May be join table, or key table, or value table.


valueTable

protected org.datanucleus.store.mapped.DatastoreClass valueTable
Table storing the values.


kmd

protected org.datanucleus.metadata.AbstractClassMetaData kmd
Metadata for the keys (if persistable).


vmd

protected org.datanucleus.metadata.AbstractClassMetaData vmd
Metadata for the values (if persistable).


keyMapping

protected org.datanucleus.store.mapped.mapping.JavaTypeMapping keyMapping
Mapping to the key from the mapTable.


valueMapping

protected org.datanucleus.store.mapped.mapping.JavaTypeMapping valueMapping
Mapping to the value from the mapTable.


keyType

protected String keyType
Type of the key.


valueType

protected String valueType
Type of the value.


keysAreEmbedded

protected boolean keysAreEmbedded
Whether the keys are embedded.


keysAreSerialised

protected boolean keysAreSerialised
Whether the keys are serialised.


valuesAreEmbedded

protected boolean valuesAreEmbedded
Whether the values are embedded.


valuesAreSerialised

protected boolean valuesAreSerialised
Whether the values are serialised.

Constructor Detail

AbstractMapStore

public AbstractMapStore(RDBMSStoreManager storeMgr)
Constructor.

Parameters:
storeMgr - Manager for the store
Method Detail

initialise

protected void initialise()
Method to initialise the statements being used. Subclasses should override the getXXXStmt() if they want to use an alternative statement.


keysAreEmbedded

public boolean keysAreEmbedded()
Accessor for whether the keys are embedded or not. If they are PC instances then returns false;

Specified by:
keysAreEmbedded in interface org.datanucleus.store.scostore.MapStore
Returns:
Whether the keys are embedded

keysAreSerialised

public boolean keysAreSerialised()
Accessor for whether the keys are serialised or not. If they are PC instances then returns false;

Specified by:
keysAreSerialised in interface org.datanucleus.store.scostore.MapStore
Returns:
Whether the keys are serialised

valuesAreEmbedded

public boolean valuesAreEmbedded()
Accessor for whether the values are embedded or not. If they are PC instances then returns false;

Specified by:
valuesAreEmbedded in interface org.datanucleus.store.scostore.MapStore
Returns:
Whether the values are embedded

valuesAreSerialised

public boolean valuesAreSerialised()
Accessor for whether the values are serialised or not. If they are PC instances then returns false;

Specified by:
valuesAreSerialised in interface org.datanucleus.store.scostore.MapStore
Returns:
Whether the values are serialised

containsKey

public boolean containsKey(org.datanucleus.store.ObjectProvider sm,
                           Object key)
Method to check if a key exists in the Map.

Specified by:
containsKey in interface org.datanucleus.store.scostore.MapStore
Parameters:
sm - State Manager for the map
key - The key to check for.
Returns:
Whether the key exists in the Map.

containsValue

public boolean containsValue(org.datanucleus.store.ObjectProvider sm,
                             Object value)
Method to check if a value exists in the Map.

Specified by:
containsValue in interface org.datanucleus.store.scostore.MapStore
Parameters:
sm - State Manager for the map
value - The value to check for.
Returns:
Whether the value exists in the Map.

get

public Object get(org.datanucleus.store.ObjectProvider sm,
                  Object key)
Method to return the value for a key.

Specified by:
get in interface org.datanucleus.store.scostore.MapStore
Parameters:
sm - State Manager for the Map.
key - The key of the object to retrieve.
Returns:
The value for this key.

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
Parameters:
sm - State Manager for the Map
m - The Map to add

validateKeyType

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

Parameters:
clr - The ClassLoaderResolver
key - The key to check.

validateValueType

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

Parameters:
clr - The ClassLoaderResolver
value - The value to check.

validateKeyForReading

protected boolean validateKeyForReading(org.datanucleus.store.ObjectProvider sm,
                                        Object key)
Utility to validate a key is ok for reading.

Parameters:
sm - State Manager for the map.
key - The key to check.
Returns:
Whether it is validated.

validateValueForReading

protected boolean validateValueForReading(org.datanucleus.store.ObjectProvider sm,
                                          Object value)
Utility to validate a value is ok for reading.

Parameters:
sm - State Manager for the map.
value - The value to check.
Returns:
Whether it is validated.

validateKeyForWriting

protected void validateKeyForWriting(org.datanucleus.store.ObjectProvider ownerOP,
                                     Object key)
Utility to validate a key is ok for writing (present in the datastore).

Parameters:
ownerOP - ObjectProvider for the owner of the map
key - The key to check.

validateValueForWriting

protected void validateValueForWriting(org.datanucleus.store.ObjectProvider ownerOP,
                                       Object value)
Utility to validate a value is ok for writing (present in the datastore).

Parameters:
ownerOP - ObjectProvider for the owner of the map
value - The value to check.

getValue

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

Parameters:
sm - State Manager for 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

updateEmbeddedKey

public boolean updateEmbeddedKey(org.datanucleus.store.ObjectProvider sm,
                                 Object key,
                                 int fieldNumber,
                                 Object newValue)
Method to update a field of an embedded key.

Specified by:
updateEmbeddedKey in interface org.datanucleus.store.scostore.MapStore
Parameters:
sm - State Manager of the owner
key - The key to update
fieldNumber - The number of the field to update
newValue - The new value

updateEmbeddedValue

public boolean updateEmbeddedValue(org.datanucleus.store.ObjectProvider sm,
                                   Object value,
                                   int fieldNumber,
                                   Object newValue)
Method to update a field of an embedded key.

Specified by:
updateEmbeddedValue in interface org.datanucleus.store.scostore.MapStore
Parameters:
sm - State Manager of the owner
value - The value to update
fieldNumber - The number of the field to update
newValue - The new value

getValueMapping

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

getKeyMapping

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

isValuesAreEmbedded

public boolean isValuesAreEmbedded()

isValuesAreSerialised

public boolean isValuesAreSerialised()

getMapTable

public org.datanucleus.store.mapped.DatastoreContainerObject getMapTable()

getKmd

public org.datanucleus.metadata.AbstractClassMetaData getKmd()

getVmd

public org.datanucleus.metadata.AbstractClassMetaData getVmd()

updateEmbeddedValue

public boolean updateEmbeddedValue(org.datanucleus.store.ObjectProvider sm,
                                   Object value,
                                   int fieldNumber,
                                   Object newValue,
                                   org.datanucleus.store.mapped.mapping.JavaTypeMapping fieldMapping)

getUpdateEmbeddedKeyStmt

protected String getUpdateEmbeddedKeyStmt(org.datanucleus.store.mapped.mapping.JavaTypeMapping fieldMapping,
                                          org.datanucleus.store.mapped.mapping.JavaTypeMapping ownerMapping,
                                          org.datanucleus.store.mapped.mapping.JavaTypeMapping keyMapping,
                                          org.datanucleus.store.mapped.DatastoreContainerObject mapTable)
Generate statement for update the field of an embedded key.
 UPDATE MAPTABLE
 SET EMBEDDEDKEYCOL1 = ?
 WHERE OWNERCOL=?
 AND EMBEDDEDKEYCOL1 = ?
 AND EMBEDDEDKEYCOL2 = ? ...
 

Parameters:
fieldMapping - The mapping for the field to be updated
ownerMapping - The owner mapping
keyMapping - The key mapping
mapTable - The map table
Returns:
Statement for updating an embedded key in the Set

getUpdateEmbeddedValueStmt

protected String getUpdateEmbeddedValueStmt(org.datanucleus.store.mapped.mapping.JavaTypeMapping fieldMapping,
                                            org.datanucleus.store.mapped.mapping.JavaTypeMapping ownerMapping,
                                            org.datanucleus.store.mapped.mapping.JavaTypeMapping valueMapping,
                                            org.datanucleus.store.mapped.DatastoreContainerObject mapTable)
Generate statement for update the field of an embedded value.
 UPDATE MAPTABLE
 SET EMBEDDEDVALUECOL1 = ?
 WHERE OWNERCOL=?
 AND EMBEDDEDVALUECOL1 = ?
 AND EMBEDDEDVALUECOL2 = ? ...
 

Parameters:
fieldMapping - The mapping for the field to be updated
ownerMapping - The owner mapping
mapTable - The map table
Returns:
Statement for updating an embedded value in the Set

updatedEmbeddedKey

public boolean updatedEmbeddedKey(org.datanucleus.store.ObjectProvider sm,
                                  Object key,
                                  int fieldNumber,
                                  Object newValue,
                                  org.datanucleus.store.mapped.mapping.JavaTypeMapping fieldMapping)


Copyright © 2012. All Rights Reserved.