org.datanucleus.store.rdbms.scostore
Class RDBMSFKListStore

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

public class RDBMSFKListStore
extends AbstractListStore

RDBMS-specific implementation of an ListStore using foreign keys.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.rdbms.scostore.ElementContainerStore
ElementContainerStore.ElementInfo
 
Field Summary
 
Fields inherited from class org.datanucleus.store.rdbms.scostore.AbstractListStore
indexedList, indexOfStmt, lastIndexOfStmt, removeAtStmt, shiftStmt
 
Fields inherited from class org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
containsStmt
 
Fields inherited from class org.datanucleus.store.rdbms.scostore.ElementContainerStore
addStmt, clearStmt, clr, containerTable, elementInfo, elementIsPersistentInterface, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, emd, iterateUsingDiscriminator, orderMapping, relationDiscriminatorMapping, relationDiscriminatorValue, removeStmt, sizeStmt, usingDiscriminatorInSizeStmt
 
Fields inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowNulls, dba, LOCALISER, ownerMapping, ownerMemberMetaData, relationType, storeMgr
 
Constructor Summary
RDBMSFKListStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)
           
 
Method Summary
 void clear(org.datanucleus.store.ObjectProvider op)
          Method to clear the List.
protected  SQLStatement getSQLStatementForIterator(org.datanucleus.store.ObjectProvider ownerSM, int startIdx, int endIdx, org.datanucleus.store.mapped.StatementClassMapping resultMapping, StatementParameterMapping paramMapping)
          Method to generate an SQLStatement for iterating through elements of the list.
protected  boolean internalAdd(org.datanucleus.store.ObjectProvider op, int startAt, boolean atEnd, Collection c, int size)
          Internal method for adding an item to the List.
protected  boolean internalRemove(org.datanucleus.store.ObjectProvider op, Object element, int size)
          Convenience method to remove the specified element from the List.
protected  void internalRemoveAt(org.datanucleus.store.ObjectProvider op, int index, int size)
          Internal method to remove an object at a location in the List.
protected  ListIterator listIterator(org.datanucleus.store.ObjectProvider ownerSM, int startIdx, int endIdx)
          Accessor for an iterator through the list elements.
protected  void manageRemovalOfElement(org.datanucleus.store.ObjectProvider ownerSM, Object element)
          Convenience method to manage the removal of an element from the collection, performing any necessary "managed relationship" updates when the field is bidirectional.
 Object set(org.datanucleus.store.ObjectProvider op, int index, Object element, boolean allowDependentField)
          Method to set an object in the List at a position.
 void update(org.datanucleus.store.ObjectProvider op, Collection coll)
          Method to update the collection to be the supplied collection of elements.
protected  boolean validateElementForWriting(org.datanucleus.store.ObjectProvider sm, Object element, int index)
          Method to validate that an element is valid for writing to the datastore.
 
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractListStore
add, add, addAll, addAll, get, getIndexOfStmt, getIndicesOf, getIndicesOfStmt, getLastIndexOfStmt, getRemoveAtStmt, getShiftStmt, indexOf, internalIndexOf, internalRemoveAt, internalShift, iterator, lastIndexOf, listIterator, remove, remove, removeAll, subList
 
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
contains, containsInternal, getRemoveStmt, getUpdateEmbeddedElementStmt, internalRemove, updateEmbeddedElement, updateEmbeddedElement
 
Methods inherited from class org.datanucleus.store.rdbms.scostore.ElementContainerStore
executeClear, getAddStmt, getClearStmt, getContainerTable, getElementInfo, getElementInformationForClass, getElementMapping, getEmd, getOrderMapping, getRelationDiscriminatorMapping, getRelationDiscriminatorValue, getSize, getSizeStmt, hasOrderMapping, invalidateAddStmt, isElementsAreEmbedded, isElementsAreSerialised, size, validateElementForReading, validateElementForWriting, validateElementType
 
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.CollectionStore
contains, hasOrderMapping, size, updateEmbeddedElement
 
Methods inherited from interface org.datanucleus.store.scostore.Store
getStoreManager
 

Constructor Detail

RDBMSFKListStore

public RDBMSFKListStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                        RDBMSStoreManager storeMgr,
                        org.datanucleus.ClassLoaderResolver clr)
Parameters:
mmd - Metadata for owning field/property
storeMgr - Manager for the datastore
clr - ClassLoader resolver
Method Detail

set

public Object set(org.datanucleus.store.ObjectProvider op,
                  int index,
                  Object element,
                  boolean allowDependentField)
Method to set an object in the List at a position.

Parameters:
op - ObjectProvider for the owner
index - The item index
element - What to set it to.
allowDependentField - Whether to enable dependent-field deletes during the set
Returns:
The value before setting.

update

public void update(org.datanucleus.store.ObjectProvider op,
                   Collection coll)
Method to update the collection to be the supplied collection of elements.

Specified by:
update in interface org.datanucleus.store.scostore.CollectionStore
Overrides:
update in class AbstractCollectionStore
Parameters:
op - ObjectProvider for the owner
coll - The collection to use

internalAdd

protected boolean internalAdd(org.datanucleus.store.ObjectProvider op,
                              int startAt,
                              boolean atEnd,
                              Collection c,
                              int size)
Internal method for adding an item to the List.

Specified by:
internalAdd in class AbstractListStore
Parameters:
op - ObjectProvider for the owner
startAt - The start position
atEnd - Whether to add at the end
c - The Collection of elements to add.
size - Current size of list (if known). -1 if not known
Returns:
Whether it was successful

internalRemove

protected boolean internalRemove(org.datanucleus.store.ObjectProvider op,
                                 Object element,
                                 int size)
Convenience method to remove the specified element from the List.

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

manageRemovalOfElement

protected void manageRemovalOfElement(org.datanucleus.store.ObjectProvider ownerSM,
                                      Object element)
Convenience method to manage the removal of an element from the collection, performing any necessary "managed relationship" updates when the field is bidirectional.

Parameters:
ownerSM - StateManager for the collection owner
element - The element

internalRemoveAt

protected void internalRemoveAt(org.datanucleus.store.ObjectProvider op,
                                int index,
                                int size)
Internal method to remove an object at a location in the List. Differs from the JoinTable List in that it nulls out the owner FK.

Specified by:
internalRemoveAt in class AbstractListStore
Parameters:
op - ObjectProvider for the owner
index - The location
size - Current size of list (if known). -1 if not known

clear

public void clear(org.datanucleus.store.ObjectProvider op)
Method to clear the List. This is called by the List.clear() method, or when the container object is being deleted and the elements are to be removed (maybe for dependent field), or also when updating a Collection and removing all existing prior to adding all new.

Specified by:
clear in interface org.datanucleus.store.scostore.CollectionStore
Overrides:
clear in class ElementContainerStore
Parameters:
op - ObjectProvider for the owner

validateElementForWriting

protected boolean validateElementForWriting(org.datanucleus.store.ObjectProvider sm,
                                            Object element,
                                            int index)
Method to validate that an element is valid for writing to the datastore. TODO Minimise differences to super.validateElementForWriting()

Parameters:
sm - StateManager for the List
element - The element to validate
index - The position that the element is being stored at in the list
Returns:
Whether the element was inserted

listIterator

protected ListIterator listIterator(org.datanucleus.store.ObjectProvider ownerSM,
                                    int startIdx,
                                    int endIdx)
Accessor for an iterator through the list elements.

Specified by:
listIterator in class AbstractListStore
Parameters:
ownerSM - State Manager for the container.
startIdx - The start index in the list (only for indexed lists)
endIdx - The end index in the list (only for indexed lists)
Returns:
The List Iterator

getSQLStatementForIterator

protected SQLStatement getSQLStatementForIterator(org.datanucleus.store.ObjectProvider ownerSM,
                                                  int startIdx,
                                                  int endIdx,
                                                  org.datanucleus.store.mapped.StatementClassMapping resultMapping,
                                                  StatementParameterMapping paramMapping)
Method to generate an SQLStatement for iterating through elements of the list. Selects the element table. Populates the resultMapping and paramMapping argument objects.

Parameters:
ownerSM - StateManager for the owner object
startIdx - start index to be retrieved (inclusive). Only for indexed list
endIdx - end index to be retrieved (exclusive). Only for indexed list
resultMapping - Mapping for the candidate result columns
paramMapping - Mapping for the input parameters
Returns:
The SQLStatement


Copyright © 2012. All Rights Reserved.