com.triactive.jdo.store
Class ManyToManyMapStore

java.lang.Object
  extended bycom.triactive.jdo.store.AbstractMapStore
      extended bycom.triactive.jdo.store.ManyToManyMapStore
All Implemented Interfaces:
MapStore

public class ManyToManyMapStore
extends com.triactive.jdo.store.AbstractMapStore

The backing store for a many-to-many map defined over a join table.

The join table has (at least) three columns, designated the "owner", "key", and "value" columns. Each {owner,key,value} triplet represents the presence of that key-value mapping in the owner's Map. The owner column must be an OID column. The key and value columns may or may not be OIDs.

The base PersistenceCapable type of the owning objects in question must be known (their ClassBaseTable must be provided).

Author:
Mike Martin

Field Summary
protected  DatabaseAdapter dba
           
 
Method Summary
 boolean allowsNullValues()
          Indicates whether null values are allowed to be stored.
 void clearAll(java.util.Collection owners)
          Clears the maps associated with an entire group of objects.
 boolean equals(java.lang.Object obj)
           
static MapStore getInstance(ClassBaseTable ownerTable, Table joinTable, ColumnMapping ownerMapping, ColumnMapping keyMapping, ColumnMapping valueMapping)
          Returns a many-to-many map store.
 java.lang.Class getKeyType()
          Returns the type of keys stored in the Map fields.
 java.lang.Class getValueType()
          Returns the type of values stored in the Map fields.
 int hashCode()
           
protected  com.triactive.jdo.store.AbstractMapStore intern()
           
 boolean isEmbeddedKey()
          Indicates whether or not keys are "embedded" in the store. An embedded object is stored by value (SCO), otherwise an OID reference is stored (FCO).
 boolean isEmbeddedValue()
          Indicates whether or not values are "embedded" in the store. An embedded object is stored by value (SCO), otherwise an OID reference is stored (FCO).
 CollectionStore keySetCollection()
          Returns a collection view of the map's key set.
 PersistentMap newMapInstance(StateManager owner)
          Returns a new persistent map representing the map associated with the given object.

Iterators returned by the map's collection views (entrySet(), keySet(), values()) support the remove() method.

protected  QueryStatement.QueryColumn[] newSubqueryStatement(QueryStatement qs, CorrelationName collectionRangeVar, Column elemColumn)
           
protected  QueryStatement.QueryColumn[] newSubqueryStatement(QueryStatement qs, CorrelationName collectionRangeVar, CorrelationName elemRangeVar, java.lang.Class elemSubtype, Column elemColumn)
           
 CollectionStore valuesCollection()
          Returns a collection view of the map's values.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dba

protected final DatabaseAdapter dba
Method Detail

getInstance

public static MapStore getInstance(ClassBaseTable ownerTable,
                                   Table joinTable,
                                   ColumnMapping ownerMapping,
                                   ColumnMapping keyMapping,
                                   ColumnMapping valueMapping)
Returns a many-to-many map store. Returns either a newly-constructed map store object, or an equivalent existing object from an internally-maintained pool.

Parameters:
ownerTable - The backing table of the owner objects.
joinTable - The table joining owners,keys to values.
ownerMapping - The mapping for the owner column in the join table.
keyMapping - The mapping for the key column in the join table.
valueMapping - The mapping for the value column in the join table.

getKeyType

public java.lang.Class getKeyType()
Returns the type of keys stored in the Map fields.


getValueType

public java.lang.Class getValueType()
Returns the type of values stored in the Map fields.


isEmbeddedKey

public boolean isEmbeddedKey()
Indicates whether or not keys are "embedded" in the store. An embedded object is stored by value (SCO), otherwise an OID reference is stored (FCO).


isEmbeddedValue

public boolean isEmbeddedValue()
Indicates whether or not values are "embedded" in the store. An embedded object is stored by value (SCO), otherwise an OID reference is stored (FCO).


allowsNullValues

public boolean allowsNullValues()
Indicates whether null values are allowed to be stored.


keySetCollection

public CollectionStore keySetCollection()
Description copied from interface: MapStore
Returns a collection view of the map's key set.


valuesCollection

public CollectionStore valuesCollection()
Description copied from interface: MapStore
Returns a collection view of the map's values.


newSubqueryStatement

protected QueryStatement.QueryColumn[] newSubqueryStatement(QueryStatement qs,
                                                            CorrelationName collectionRangeVar,
                                                            Column elemColumn)

newSubqueryStatement

protected QueryStatement.QueryColumn[] newSubqueryStatement(QueryStatement qs,
                                                            CorrelationName collectionRangeVar,
                                                            CorrelationName elemRangeVar,
                                                            java.lang.Class elemSubtype,
                                                            Column elemColumn)

newMapInstance

public PersistentMap newMapInstance(StateManager owner)
Returns a new persistent map representing the map associated with the given object.

Iterators returned by the map's collection views (entrySet(), keySet(), values()) support the remove() method.

Parameters:
owner - The StateManager of the object whose set is to be returned.
Returns:
the new persistent map

hashCode

public int hashCode()

equals

public boolean equals(java.lang.Object obj)

intern

protected com.triactive.jdo.store.AbstractMapStore intern()

clearAll

public void clearAll(java.util.Collection owners)
Clears the maps associated with an entire group of objects.

The implementation in this class simply iterates over the owners, and calls newMapInstance(o).clear() on each one. Like SetStore.clearAll(java.util.Collection) there are opportunities for further optimization here.

Specified by:
clearAll in interface MapStore
Parameters:
owners - The StateManagers of all the objects whose set is to be cleared.


Copyright 2001-2007 The TJDO Project All Rights Reserved.