Class FKListStore<E>
- java.lang.Object
-
- org.datanucleus.store.rdbms.scostore.BaseContainerStore
-
- org.datanucleus.store.rdbms.scostore.ElementContainerStore
-
- org.datanucleus.store.rdbms.scostore.AbstractCollectionStore<E>
-
- org.datanucleus.store.rdbms.scostore.AbstractListStore<E>
-
- org.datanucleus.store.rdbms.scostore.FKListStore<E>
-
- All Implemented Interfaces:
org.datanucleus.store.types.scostore.CollectionStore<E>,org.datanucleus.store.types.scostore.ListStore<E>,org.datanucleus.store.types.scostore.Store
public class FKListStore<E> extends AbstractListStore<E>
RDBMS-specific implementation of anListStoreusing foreign keys.
-
-
Field Summary
-
Fields inherited from class org.datanucleus.store.rdbms.scostore.AbstractListStore
indexedList, indexOfStmt, lastIndexOfStmt, removeAtStmt, shiftBulkStmt, shiftStmt
-
Fields inherited from class org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
containsStmt
-
Fields inherited from class org.datanucleus.store.rdbms.scostore.ElementContainerStore
addStmt, clearStmt, containerTable, elementCmd, elementInfo, elementIsPersistentInterface, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, iterateUsingDiscriminator, orderMapping, relationDiscriminatorMapping, relationDiscriminatorValue, removeStmt, sizeStmt
-
Fields inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowNulls, clr, dba, ownerMapping, ownerMemberMetaData, relationType, storeMgr
-
-
Constructor Summary
Constructors Constructor Description FKListStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear(org.datanucleus.state.ObjectProvider ownerOP)Method to clear the List.ElementIteratorStatementgetIteratorStatement(org.datanucleus.ExecutionContext ec, org.datanucleus.FetchPlan fp, boolean addRestrictionOnOwner, int startIdx, int endIdx)Method to return the SQLStatement and mapping for an iterator for this backing store.protected booleaninternalAdd(org.datanucleus.state.ObjectProvider ownerOP, int startAt, boolean atEnd, Collection<E> c, int size)Internal method for adding an item to the List.protected booleaninternalRemove(org.datanucleus.state.ObjectProvider ownerOP, Object element, int size)Convenience method to remove the specified element from the List.protected voidinternalRemoveAt(org.datanucleus.state.ObjectProvider ownerOP, int index, int size)Internal method to remove an object at a location in the List.protected ListIterator<E>listIterator(org.datanucleus.state.ObjectProvider ownerOP, int startIdx, int endIdx)Accessor for an iterator through the list elements.protected voidmanageRemovalOfElement(org.datanucleus.state.ObjectProvider ownerOP, 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.booleanremoveAll(org.datanucleus.state.ObjectProvider ownerOP, Collection elements, int size)Remove all elements from a collection from the association owner vs elements.Eset(org.datanucleus.state.ObjectProvider ownerOP, int index, Object element, boolean allowDependentField)Method to set an object in the List at a position.voidupdate(org.datanucleus.state.ObjectProvider ownerOP, Collection coll)Method to update the collection to be the supplied collection of elements.protected booleanvalidateElementForWriting(org.datanucleus.state.ObjectProvider op, 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, getShiftBulkStmt, getShiftStmt, indexOf, internalIndexOf, internalRemoveAt, internalShift, internalShiftBulk, iterator, lastIndexOf, listIterator, remove, remove, subList
-
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
contains, getRemoveStmt, getUpdateEmbeddedElementStmt, updateEmbeddedElement, updateEmbeddedElement
-
Methods inherited from class org.datanucleus.store.rdbms.scostore.ElementContainerStore
getAddStmtForJoinTable, getClearStmt, getComponentInfoForElement, getContainerTable, getElementClassMetaData, getElementMapping, getRelationDiscriminatorMapping, getRelationDiscriminatorValue, getSize, getSizeStmt, hasOrderMapping, invalidateAddStmt, isElementsAreEmbedded, isElementsAreSerialised, size, usingJoinTable, validateElementForReading, validateElementForWriting, validateElementType
-
Methods inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowsBatching, getComponentInformationForClass, getDatastoreAdapter, getObjectProviderForEmbeddedPCObject, getOwnerMapping, getOwnerMemberMetaData, getRelationType, getStoreManager, isEmbeddedMapping, setOwner
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
FKListStore
public FKListStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)- Parameters:
mmd- Metadata for owning field/propertystoreMgr- Manager for the datastoreclr- ClassLoader resolver
-
-
Method Detail
-
set
public E set(org.datanucleus.state.ObjectProvider ownerOP, int index, Object element, boolean allowDependentField)
Method to set an object in the List at a position.- Parameters:
ownerOP- ObjectProvider for the ownerindex- The item indexelement- 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.state.ObjectProvider ownerOP, Collection coll)Method to update the collection to be the supplied collection of elements.- Specified by:
updatein interfaceorg.datanucleus.store.types.scostore.CollectionStore<E>- Overrides:
updatein classAbstractCollectionStore<E>- Parameters:
ownerOP- ObjectProvider for the ownercoll- The collection to use
-
internalAdd
protected boolean internalAdd(org.datanucleus.state.ObjectProvider ownerOP, int startAt, boolean atEnd, Collection<E> c, int size)Internal method for adding an item to the List.- Specified by:
internalAddin classAbstractListStore<E>- Parameters:
ownerOP- ObjectProvider for the ownerstartAt- The start positionatEnd- Whether to add at the endc- The Collection of elements to add.size- Current size of list (if known). -1 if not known- Returns:
- Whether it was successful
-
removeAll
public boolean removeAll(org.datanucleus.state.ObjectProvider ownerOP, Collection elements, int size)Remove all elements from a collection from the association owner vs elements. TODO : Change the query to do all in one go for efficiency. Currently removes an element and shuffles the indexes, then removes an element and shuffles the indexes, then removes an element and shuffles the indexes etc ... a bit inefficient !!!- Parameters:
ownerOP- ObjectProvider for the ownerelements- Collection of elements to remove- Returns:
- Whether the database was updated
-
internalRemove
protected boolean internalRemove(org.datanucleus.state.ObjectProvider ownerOP, Object element, int size)Convenience method to remove the specified element from the List.- Specified by:
internalRemovein classAbstractListStore<E>- Parameters:
ownerOP- ObjectProvider for the ownerelement- The elementsize- Current size of list if known. -1 if not known- Returns:
- Whether the List was modified
-
manageRemovalOfElement
protected void manageRemovalOfElement(org.datanucleus.state.ObjectProvider ownerOP, 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:
ownerOP- ObjectProvider for the collection ownerelement- The element
-
internalRemoveAt
protected void internalRemoveAt(org.datanucleus.state.ObjectProvider ownerOP, 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:
internalRemoveAtin classAbstractListStore<E>- Parameters:
ownerOP- ObjectProvider for the ownerindex- The locationsize- Current size of list (if known). -1 if not known
-
clear
public void clear(org.datanucleus.state.ObjectProvider ownerOP)
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:
clearin interfaceorg.datanucleus.store.types.scostore.CollectionStore<E>- Overrides:
clearin classElementContainerStore- Parameters:
ownerOP- ObjectProvider for the owner
-
validateElementForWriting
protected boolean validateElementForWriting(org.datanucleus.state.ObjectProvider op, Object element, int index)Method to validate that an element is valid for writing to the datastore. TODO Minimise differences to super.validateElementForWriting()- Parameters:
op- ObjectProvider for the Listelement- The element to validateindex- The position that the element is being stored at in the list- Returns:
- Whether the element was inserted
-
listIterator
protected ListIterator<E> listIterator(org.datanucleus.state.ObjectProvider ownerOP, int startIdx, int endIdx)
Accessor for an iterator through the list elements.- Specified by:
listIteratorin classAbstractListStore<E>- Parameters:
ownerOP- ObjectProvider for the owner.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
-
getIteratorStatement
public ElementIteratorStatement getIteratorStatement(org.datanucleus.ExecutionContext ec, org.datanucleus.FetchPlan fp, boolean addRestrictionOnOwner, int startIdx, int endIdx)
Method to return the SQLStatement and mapping for an iterator for this backing store. Create a statement of the formSELECT ELEM_COLS FROM ELEM_TBL [WHERE] [ELEM_TBL.OWNER_ID = {value}] [AND] [ELEM_TBL.DISCRIM = {discrimValue}] [ORDER BY {orderClause}]- Parameters:
ec- ExecutionContextfp- FetchPlan to use in determing which fields of element to selectaddRestrictionOnOwner- Whether to restrict to a particular owner (otherwise functions as bulk fetch for many owners).startIdx- Start index for the iterator (or -1)endIdx- End index for the iterator (or -1)- Returns:
- The SQLStatement and its associated StatementClassMapping
-
-