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
Implementation of a
ListStore using join table.-
Field Summary
FieldsFields inherited from class org.datanucleus.store.rdbms.scostore.AbstractListStore
indexedList, indexOfStmt, lastIndexOfStmt, removeAtStmt, shiftBulkStmt, shiftStmtFields inherited from class org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
containsStmtFields inherited from class org.datanucleus.store.rdbms.scostore.ElementContainerStore
addStmt, clearStmt, containerTable, elementCmd, elementInfo, elementIsPersistentInterface, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, iterateUsingDiscriminator, orderMapping, relationDiscriminatorMapping, relationDiscriminatorValue, removeStmt, sizeStmtFields inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowNulls, clr, dba, ownerMapping, ownerMemberMetaData, relationType, storeMgr -
Constructor Summary
ConstructorsConstructorDescriptionJoinListStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, CollectionTable joinTable, org.datanucleus.ClassLoaderResolver clr) Constructor for a join list store for RDBMS. -
Method Summary
Modifier and TypeMethodDescriptiongetIteratorStatement(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 StringgetRemoveAllStmt(Collection elements) Generate statement for removing a collection of items from the List.protected StringGenerates the statement for setting an item.protected booleaninternalAdd(org.datanucleus.state.DNStateManager ownerSM, int start, boolean atEnd, Collection<? extends E> c, int size) Internal method to add element(s) to the List.protected booleaninternalRemove(org.datanucleus.state.DNStateManager ownerSM, 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, Object element, boolean executeNow) protected voidinternalRemoveAt(org.datanucleus.state.DNStateManager ownerSM, int index, int size) Method to remove an element from the specified positionprotected ListIterator<E> listIterator(org.datanucleus.state.DNStateManager ownerSM, int startIdx, int endIdx) Accessor for an iterator through the list elements.remove(org.datanucleus.state.DNStateManager ownerSM, int index, int size) booleanremoveAll(org.datanucleus.state.DNStateManager ownerSM, Collection elements, int size) booleanremoveAll(org.datanucleus.state.DNStateManager ownerSM, Collection elements, int size, int[] elementIndices) set(org.datanucleus.state.DNStateManager ownerSM, int index, E element, boolean allowDependentField) voidupdate(org.datanucleus.state.DNStateManager ownerSM, 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, subListMethods inherited from class org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
contains, getRemoveStmt, getUpdateEmbeddedElementStmt, updateEmbeddedElementMethods 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, validateElementTypeMethods inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowsBatching, getComponentInformationForClass, getDatastoreAdapter, getOwnerMapping, getOwnerMemberMetaData, getRelationType, getStateManagerForEmbeddedPCObject, getStoreManager, isEmbeddedMapping, setOwnerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.datanucleus.store.types.scostore.CollectionStore
clear, contains, hasOrderMapping, size, updateEmbeddedElementMethods inherited from interface org.datanucleus.store.types.scostore.Store
getOwnerMemberMetaData, getStoreManager
-
Field Details
-
setStmt
-
elementCls
-
-
Constructor Details
-
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 Details
-
internalAdd
protected boolean internalAdd(org.datanucleus.state.DNStateManager ownerSM, int start, boolean atEnd, 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
-
update
- Specified by:
updatein interfaceorg.datanucleus.store.types.scostore.CollectionStore<E>- Overrides:
updatein classAbstractCollectionStore<E>
-
remove
-
internalRemove
protected boolean internalRemove(org.datanucleus.state.DNStateManager ownerSM, Object element, int size) Convenience method to remove the specified element from the List.- Specified by:
internalRemovein classAbstractListStore<E>- Parameters:
ownerSM- StateManager of the ownerelement- The elementsize- 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, Object element, boolean executeNow) -
removeAll
public boolean removeAll(org.datanucleus.state.DNStateManager ownerSM, Collection elements, int size) -
removeAll
public boolean removeAll(org.datanucleus.state.DNStateManager ownerSM, 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 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
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
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
-