org.jpox.store.rdbms.scostore
Class MapValueSetStore

java.lang.Object
  extended byorg.jpox.store.rdbms.scostore.BaseContainerStore
      extended byorg.jpox.store.rdbms.scostore.ElementContainerStore
          extended byorg.jpox.store.rdbms.scostore.AbstractCollectionStore
              extended byorg.jpox.store.rdbms.scostore.AbstractSetStore
                  extended byorg.jpox.store.rdbms.scostore.MapValueSetStore
All Implemented Interfaces:
CollectionStore, SetStore, Store

public class MapValueSetStore
extends org.jpox.store.rdbms.scostore.AbstractSetStore

Representation of the backing store for a MapValue Set. This is used where the user calls Map.values() and then wants to perform some operation on the resulting Collection. TODO Cater for embedded values.

Version:
$Revision: 1.40 $

Nested Class Summary
 
Nested classes inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore
ElementContainerStore.ElementInfo
 
Field Summary
protected  java.lang.String addStmt
           
protected  java.lang.String removeStmt
           
protected  java.lang.String setName
           
 
Fields inherited from class org.jpox.store.rdbms.scostore.AbstractCollectionStore
containsStmt
 
Fields inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore
clearStmt, clr, containerTable, dba, elementInfo, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, elmIdentifier, emd, iterateUsingDiscriminator, LOCALISER, orderMapping, ownerFieldMetaData, ownerMapping, relationDiscriminatorMapping, relationDiscriminatorValue, sizeStmt, storeMgr, thisIdentifier
 
Constructor Summary
MapValueSetStore(DatastoreClass valueTable, JavaTypeMapping ownerMapping, MapStore mapStore, ClassLoaderResolver clr)
          Constructor.
MapValueSetStore(MapTable mapTable, MapStore mapStore, ClassLoaderResolver clr)
          Constructor.
 
Method Summary
 boolean add(StateManager sm, java.lang.Object element)
          Method to add a value to the Map.
 boolean addAll(StateManager sm, java.util.Collection elements)
          Adds all elements from a collection to the association owner vs elements
 void clear(StateManager sm)
          Method to clear the map.
protected  QueryExpression getIteratorStatement(StateManager ownerSM)
          Accessor for the statement for the iterator.
protected  java.lang.String getRemoveStmt()
          Generate statement for deleting an item from the Set.
protected  void initialiseStatements()
          Method to initialise the statements being used.
 java.util.Iterator iterator(StateManager ownerSM)
          Accessor for an iterator for the set.
 ScalarExpression joinElementsTo(QueryExpression stmt, QueryExpression qs, JavaTypeMapping ownerMapping, LogicSetExpression te, DatastoreIdentifier setRangeVar, java.lang.Class filteredElementType, ScalarExpression elmExpr, DatastoreIdentifier elementRangeVar)
          Method used in queries when contains() has been invoked.
 QueryExpression newQueryStatement(StateManager sm, java.lang.String candidateClass)
          Method to return a new Query Statement containing the candidate class.
 boolean remove(StateManager sm, java.lang.Object element)
          Method to remove a value from the Map.
 boolean removeAll(StateManager sm, java.util.Collection elements)
          Remove all elements from a collection from the association owner vs elements.
 
Methods inherited from class org.jpox.store.rdbms.scostore.AbstractCollectionStore
contains, getContainsStmt, getExistsSubquery, getSizeSubquery, getUpdateEmbeddedElementStmt, updateEmbeddedElement
 
Methods inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore
executeQuery, executeUpdate, getAddStmt, getClearStmt, getElementInformationForClass, getElementType, getOwnerMapping, getSizeStmt, getStateManagerForEmbeddedPCObject, getStoreManager, hasOrderMapping, isEmbeddedMapping, newResultObjectFactory, populateElementDiscriminatorInStatement, populateElementInStatement, populateEmbeddedElementFieldsInStatement, populateOrderInStatement, populateOwnerInStatement, populateRelationDiscriminatorInStatement, size, validateElementForReading, validateElementForWriting, validateElementType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jpox.store.scostore.CollectionStore
contains, getElementType, getExistsSubquery, getSizeSubquery, hasOrderMapping, newResultObjectFactory, size, updateEmbeddedElement
 
Methods inherited from interface org.jpox.store.scostore.Store
getOwnerMapping, getStoreManager
 

Field Detail

setName

protected java.lang.String setName

addStmt

protected java.lang.String addStmt

removeStmt

protected java.lang.String removeStmt
Constructor Detail

MapValueSetStore

public MapValueSetStore(MapTable mapTable,
                        MapStore mapStore,
                        ClassLoaderResolver clr)
Constructor.

Parameters:
mapTable - Table used by the map
mapStore - Store used by the map
clr - The ClassLoaderResolver

MapValueSetStore

public MapValueSetStore(DatastoreClass valueTable,
                        JavaTypeMapping ownerMapping,
                        MapStore mapStore,
                        ClassLoaderResolver clr)
Constructor.

Parameters:
valueTable - Table for the values
ownerMapping - Mapping to the owner
mapStore - Store used by the map.
clr - The ClassLoaderResolver
Method Detail

getIteratorStatement

protected QueryExpression getIteratorStatement(StateManager ownerSM)
Accessor for the statement for the iterator.

Parameters:
ownerSM - the owner StateManager
Returns:
The iterator Query Statement.

add

public boolean add(StateManager sm,
                   java.lang.Object element)
Method to add a value to the Map. Not supported.

Parameters:
sm - State Manager for the owner
element - The value to add
Returns:
Whether it was added correctly.

remove

public boolean remove(StateManager sm,
                      java.lang.Object element)
Method to remove a value from the Map.

Parameters:
sm - State Manager for the owner
element - The value to remove
Returns:
Whether it was removed correctly.

clear

public void clear(StateManager sm)
Method to clear the map.

Specified by:
clear in interface CollectionStore
Overrides:
clear in class ElementContainerStore
Parameters:
sm - State Manager for the container.

newQueryStatement

public QueryExpression newQueryStatement(StateManager sm,
                                         java.lang.String candidateClass)
Description copied from interface: CollectionStore
Method to return a new Query Statement containing the candidate class.

Parameters:
sm - State Manager for the collection.
candidateClass - Class of the elements.
Returns:
The Query Statement.

joinElementsTo

public ScalarExpression joinElementsTo(QueryExpression stmt,
                                       QueryExpression qs,
                                       JavaTypeMapping ownerMapping,
                                       LogicSetExpression te,
                                       DatastoreIdentifier setRangeVar,
                                       java.lang.Class filteredElementType,
                                       ScalarExpression elmExpr,
                                       DatastoreIdentifier elementRangeVar)
Description copied from interface: CollectionStore
Method used in queries when contains() has been invoked.

Parameters:
stmt - The Query Statement
qs - the parent Query Statement. If there is no parent, parentStmt must be equals to stmt
ownerMapping - the mapping for the owner.
te - Table Expression for the owner
setRangeVar - The range variable for the "Collection" table.
filteredElementType - The Class Type for the filtered element
elmExpr - The Expression for the element
elementRangeVar - The SQL alias, or "range variable", to assign to the expression or to the element table.
Returns:
expression to the join

initialiseStatements

protected void initialiseStatements()
Method to initialise the statements being used.

Overrides:
initialiseStatements in class AbstractCollectionStore

iterator

public java.util.Iterator iterator(StateManager ownerSM)
Accessor for an iterator for the set.

Specified by:
iterator in interface CollectionStore
Specified by:
iterator in class ElementContainerStore
Parameters:
ownerSM - State Manager for the set.
Returns:
Iterator for the set.

addAll

public boolean addAll(StateManager sm,
                      java.util.Collection elements)
Adds all elements from a collection to the association owner vs elements

Specified by:
addAll in interface CollectionStore
Parameters:
sm - State Manager for the container
elements - The elements to add
Returns:
Whether it was successful

removeAll

public boolean removeAll(StateManager sm,
                         java.util.Collection elements)
Remove all elements from a collection from the association owner vs elements. This implementation iterates around the remove() method doing each element 1 at a time. Please refer to the NormalSetStore and InverseSetStore for the variations used there.

Specified by:
removeAll in interface CollectionStore
Parameters:
sm - State Manager for the container
elements - Collection of elements to remove
Returns:
Whether the database was updated

getRemoveStmt

protected java.lang.String getRemoveStmt()
Generate statement for deleting an item from the Set.
 DELETE FROM SETTABLE 
 WHERE OWNERCOL=?
 AND ELEMENTCOL = ?
 [AND DISCRIM = ?]
 

Returns:
Statement for deleting an item from the Set.


Copyright © -2007 . All Rights Reserved.