com.triactive.jdo.store
Class OneToManyMapStore

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

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

The backing store for a one-to-many map defined over the class base table of its values.

The value class has two fields designated the "owner" and "key" fields, both of which must map to a single column in its backing table. Each row having a non-null owner represents the presence of a mapping from that key to that value in the owner's Map. The owner column must be an OID column. The key column may or may not be an OID.

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, ClassBaseTable valueTable, int ownerFieldNumber, int keyFieldNumber)
          Returns a one-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 setRangeVar, Column elemColumn)
           
protected  QueryStatement.QueryColumn[] newSubqueryStatement(QueryStatement qs, CorrelationName setRangeVar, 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,
                                   ClassBaseTable valueTable,
                                   int ownerFieldNumber,
                                   int keyFieldNumber)
Returns a one-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.
valueTable - The backing table of the value objects.
ownerFieldNumber - The absolute field number of the owner field in the value class.
keyFieldNumber - The absolute field number of the key field in the value class.

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 setRangeVar,
                                                            Column elemColumn)

newSubqueryStatement

protected QueryStatement.QueryColumn[] newSubqueryStatement(QueryStatement qs,
                                                            CorrelationName setRangeVar,
                                                            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.