Class JoinListStore<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.JoinListStore<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 JoinListStore<E> extends AbstractListStore<E>
Implementation of aListStoreusing join table.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<E>elementClsprivate java.lang.StringsetStmt-
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 JoinListStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, CollectionTable joinTable, org.datanucleus.ClassLoaderResolver clr)Constructor for a join list store for RDBMS.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 java.lang.StringgetRemoveAllStmt(java.util.Collection elements)Generate statement for removing a collection of items from the List.protected java.lang.StringgetSetStmt()Generates the statement for setting an item.protected booleaninternalAdd(org.datanucleus.state.DNStateManager ownerSM, int start, boolean atEnd, java.util.Collection<? extends E> c, int size)Internal method to add element(s) to the List.protected booleaninternalRemove(org.datanucleus.state.DNStateManager ownerSM, java.lang.Object element, int size)Convenience method to remove the specified element from the List.private int[]internalRemove(org.datanucleus.state.DNStateManager ownerSM, org.datanucleus.store.connection.ManagedConnection conn, boolean batched, java.lang.Object element, boolean executeNow)protected voidinternalRemoveAt(org.datanucleus.state.DNStateManager ownerSM, int index, int size)Method to remove an element from the specified positionprotected java.util.ListIterator<E>listIterator(org.datanucleus.state.DNStateManager ownerSM, int startIdx, int endIdx)Accessor for an iterator through the list elements.Eremove(org.datanucleus.state.DNStateManager ownerSM, int index, int size)booleanremoveAll(org.datanucleus.state.DNStateManager ownerSM, java.util.Collection elements, int size)booleanremoveAll(org.datanucleus.state.DNStateManager ownerSM, java.util.Collection elements, int size, int[] elementIndices)Eset(org.datanucleus.state.DNStateManager ownerSM, int index, E element, boolean allowDependentField)voidupdate(org.datanucleus.state.DNStateManager ownerSM, java.util.Collection<? extends E> coll)-
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, subList
-
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
contains, getRemoveStmt, getUpdateEmbeddedElementStmt, updateEmbeddedElement
-
Methods inherited from class org.datanucleus.store.rdbms.scostore.ElementContainerStore
clear, 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, 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
-
-
-
-
Field Detail
-
setStmt
private java.lang.String setStmt
-
elementCls
private java.lang.Class<E> elementCls
-
-
Constructor Detail
-
JoinListStore
public JoinListStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, CollectionTable joinTable, org.datanucleus.ClassLoaderResolver clr)Constructor for a join list store for RDBMS.- Parameters:
mmd- Metadata for the member that has the list with join tablejoinTable- The Join tableclr- ClassLoader resolver
-
-
Method Detail
-
internalAdd
protected boolean internalAdd(org.datanucleus.state.DNStateManager ownerSM, int start, boolean atEnd, java.util.Collection<? extends E> c, int size)Internal method to add element(s) to the List. Performs the add in 2 steps.- Shift all existing elements into their new positions so we can insert.
- Insert all new elements directly at their desired positions
- Specified by:
internalAddin classAbstractListStore<E>- Parameters:
ownerSM- StateManager for the list ownerstart- The start location (if required)atEnd- Whether to add the element at the endc- The collection of objects to add.size- Current size of list if known. -1 if not known- Returns:
- Whether it was successful
-
set
public E set(org.datanucleus.state.DNStateManager ownerSM, int index, E element, boolean allowDependentField)
-
update
public void update(org.datanucleus.state.DNStateManager ownerSM, java.util.Collection<? extends E> coll)- Specified by:
updatein interfaceorg.datanucleus.store.types.scostore.CollectionStore<E>- Overrides:
updatein classAbstractCollectionStore<E>
-
remove
public E remove(org.datanucleus.state.DNStateManager ownerSM, int index, int size)
-
internalRemove
protected boolean internalRemove(org.datanucleus.state.DNStateManager ownerSM, java.lang.Object element, int size)Convenience method to remove the specified element from the List.- Specified by:
internalRemovein classAbstractListStore<E>- Parameters:
element- The elementownerSM- StateManager of the ownersize- Current size of list if known. -1 if not known- Returns:
- Whether the List was modified
-
internalRemove
private int[] internalRemove(org.datanucleus.state.DNStateManager ownerSM, org.datanucleus.store.connection.ManagedConnection conn, boolean batched, java.lang.Object element, boolean executeNow)
-
removeAll
public boolean removeAll(org.datanucleus.state.DNStateManager ownerSM, java.util.Collection elements, int size)
-
removeAll
public boolean removeAll(org.datanucleus.state.DNStateManager ownerSM, java.util.Collection elements, int size, int[] elementIndices)
-
internalRemoveAt
protected void internalRemoveAt(org.datanucleus.state.DNStateManager ownerSM, int index, int size)Method to remove an element from the specified position- Parameters:
ownerSM- StateManager for the list ownerindex- The index of the elementsize- Current size of list (if known). -1 if not known
-
listIterator
protected java.util.ListIterator<E> listIterator(org.datanucleus.state.DNStateManager ownerSM, int startIdx, int endIdx)
Accessor for an iterator through the list elements.- Specified by:
listIteratorin classAbstractListStore<E>- Parameters:
ownerSM- StateManager for the list ownerstartIdx- The start point in the list (only for indexed lists).endIdx- End index in the list (only for indexed lists).- Returns:
- The List Iterator
-
getSetStmt
protected java.lang.String getSetStmt()
Generates the statement for setting an item.UPDATE LISTTABLE SET [ELEMENTCOL = ?] [EMBEDDEDFIELD1=?, EMBEDDEDFIELD2=?, ...] WHERE OWNERCOL = ? AND INDEXCOL = ? [AND DISTINGUISHER=?]
- Returns:
- The Statement for setting an item
-
getRemoveAllStmt
protected java.lang.String getRemoveAllStmt(java.util.Collection elements)
Generate statement for removing a collection of items from the List.DELETE FROM LISTTABLE WHERE (OWNERCOL=? AND ELEMENTCOL=?) OR (OWNERCOL=? AND ELEMENTCOL=?) OR (OWNERCOL=? AND ELEMENTCOL=?)
- Parameters:
elements- Collection of elements to remove- Returns:
- Statement for deleting items from the List.
-
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 JOIN_TBL [JOIN ELEM_TBL ON ELEM_TBL.ID = JOIN_TBL.ELEM_ID] [WHERE] [JOIN_TBL.OWNER_ID = {value}] [AND] [JOIN_TBL.DISCRIM = {discrimValue}] [ORDER BY {orderClause}]This is public to provide access for BulkFetchXXXHandler class(es).- 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
-
-