org.datanucleus.store.mapped.scostore
Class JoinListStore

java.lang.Object
  extended by org.datanucleus.store.mapped.scostore.BaseContainerStore
      extended by org.datanucleus.store.mapped.scostore.ElementContainerStore
          extended by org.datanucleus.store.mapped.scostore.AbstractCollectionStore
              extended by org.datanucleus.store.mapped.scostore.AbstractListStore
                  extended by org.datanucleus.store.mapped.scostore.JoinListStore
All Implemented Interfaces:
CollectionStore, ListStore, Store

public abstract class JoinListStore
extends AbstractListStore

Representation of the backing store for a join-table List. Uses a Join table, so we use 3 tables - owner table, join table and element table.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.mapped.scostore.ElementContainerStore
ElementContainerStore.ElementInfo
 
Field Summary
 
Fields inherited from class org.datanucleus.store.mapped.scostore.AbstractListStore
indexedList
 
Fields inherited from class org.datanucleus.store.mapped.scostore.ElementContainerStore
clr, containerTable, elementInfo, elementIsPersistentInterface, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, emd, iterateUsingDiscriminator, orderMapping, relationDiscriminatorMapping, relationDiscriminatorValue, specialization
 
Fields inherited from class org.datanucleus.store.mapped.scostore.BaseContainerStore
allowNulls, dba, LOCALISER, ownerMapping, ownerMemberMetaData, relationType, storeMgr
 
Constructor Summary
JoinListStore(AbstractMemberMetaData fmd, ClassLoaderResolver clr, DatastoreContainerObject joinTable, JavaTypeMapping ownerMapping, JavaTypeMapping elementMapping, JavaTypeMapping orderMapping, JavaTypeMapping relationDiscriminatorMapping, java.lang.String relationDiscriminatorValue, boolean elementsAreEmbedded, boolean elementsAreSerialised, JoinListStoreSpecialization specialization)
          Constructor.
 
Method Summary
protected  boolean internalAdd(ObjectProvider sm, int start, boolean atEnd, java.util.Collection c, int size)
          Internal method to add element(s) to the List.
protected  boolean internalRemove(ObjectProvider ownerSM, java.lang.Object element, int size)
          Convenience method to remove the specified element from the List.
 boolean removeAll(ObjectProvider sm, java.util.Collection elements, int size)
          Remove all elements from a collection from the association owner vs elements.
protected  void removeAt(ObjectProvider sm, int index, int size)
          Method to remove an element from the specified position
 java.lang.Object set(ObjectProvider sm, int index, java.lang.Object element, boolean allowDependentField)
          Method to set an object in the List.
 void update(ObjectProvider sm, java.util.Collection coll)
          Method to update the collection to be the supplied collection of elements.
 
Methods inherited from class org.datanucleus.store.mapped.scostore.AbstractListStore
add, add, addAll, addAll, get, getIndicesOf, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, subList
 
Methods inherited from class org.datanucleus.store.mapped.scostore.AbstractCollectionStore
contains, updateEmbeddedElement
 
Methods inherited from class org.datanucleus.store.mapped.scostore.ElementContainerStore
clear, getContainerTable, getElementInfo, getElementInformationForClass, getElementMapping, getElementType, getEmd, getOrderMapping, getRelationDiscriminatorMapping, getRelationDiscriminatorValue, hasOrderMapping, isElementsAreEmbedded, isElementsAreSerialised, size, validateElementForReading, validateElementForWriting, validateElementType
 
Methods inherited from class org.datanucleus.store.mapped.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.CollectionStore
clear, contains, getElementType, hasOrderMapping, size, updateEmbeddedElement
 
Methods inherited from interface org.datanucleus.store.scostore.Store
getStoreManager
 

Constructor Detail

JoinListStore

public JoinListStore(AbstractMemberMetaData fmd,
                     ClassLoaderResolver clr,
                     DatastoreContainerObject joinTable,
                     JavaTypeMapping ownerMapping,
                     JavaTypeMapping elementMapping,
                     JavaTypeMapping orderMapping,
                     JavaTypeMapping relationDiscriminatorMapping,
                     java.lang.String relationDiscriminatorValue,
                     boolean elementsAreEmbedded,
                     boolean elementsAreSerialised,
                     JoinListStoreSpecialization specialization)
Constructor.

Parameters:
clr - ClassLoader resolver
Method Detail

internalAdd

protected boolean internalAdd(ObjectProvider sm,
                              int start,
                              boolean atEnd,
                              java.util.Collection c,
                              int size)
Internal method to add element(s) to the List. Performs the add in 2 steps.
  1. Shift all existing elements into their new positions so we can insert.
  2. Insert all new elements directly at their desired positions>/li>
Both steps can be batched (separately).

Specified by:
internalAdd in class AbstractListStore
Parameters:
sm - The state manager
start - The start location (if required)
atEnd - Whether to add the element at the end
c - The collection of objects to add.
size - Current size of list if known. -1 if not known
Returns:
Whether it was successful

set

public java.lang.Object set(ObjectProvider sm,
                            int index,
                            java.lang.Object element,
                            boolean allowDependentField)
Method to set an object in the List.

Parameters:
sm - The state manager
index - The item index
element - What to set it to.
allowDependentField - Whether to allow dependent field deletes
Returns:
The value before setting.

update

public void update(ObjectProvider sm,
                   java.util.Collection coll)
Method to update the collection to be the supplied collection of elements.

Specified by:
update in interface CollectionStore
Overrides:
update in class AbstractCollectionStore
Parameters:
sm - StateManager of the object
coll - The collection to use

internalRemove

protected boolean internalRemove(ObjectProvider ownerSM,
                                 java.lang.Object element,
                                 int size)
Convenience method to remove the specified element from the List.

Specified by:
internalRemove in class AbstractListStore
Parameters:
element - The element
ownerSM - StateManager of the owner
size - Current size of list if known. -1 if not known
Returns:
Whether the List was modified

removeAll

public boolean removeAll(ObjectProvider sm,
                         java.util.Collection elements,
                         int size)
Remove all elements from a collection from the association owner vs elements. Performs the removal in 3 steps. The first gets the indices that will be removed (and the highest index present). The second step removes these elements from the list. The third step updates the indices of the remaining indices to fill the holes created.

Specified by:
removeAll in interface CollectionStore
Overrides:
removeAll in class AbstractListStore
Parameters:
sm - State Manager for the container
elements - Collection of elements to remove
size - Current size of collection if known. -1 if not known
Returns:
Whether the database was updated

removeAt

protected void removeAt(ObjectProvider sm,
                        int index,
                        int size)
Method to remove an element from the specified position

Specified by:
removeAt in class AbstractListStore
Parameters:
sm - The State Manager for the list
index - The index of the element
size - Current size of list (if known). -1 if not known


Copyright © 2011. All Rights Reserved.