Class JoinSetStore<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.AbstractSetStore<E>
-
- org.datanucleus.store.rdbms.scostore.JoinSetStore<E>
-
- All Implemented Interfaces:
org.datanucleus.store.types.scostore.CollectionStore<E>
,org.datanucleus.store.types.scostore.SetStore<E>
,org.datanucleus.store.types.scostore.Store
public class JoinSetStore<E> extends AbstractSetStore<E>
Implementation of aSetStore
using join table.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
locateStmt
Statement to check the existence of an owner-element relation.protected String
maxOrderColumnIdStmt
Statement to get the maximum order column id so we can set the next insert value.-
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 JoinSetStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, CollectionTable joinTable, org.datanucleus.ClassLoaderResolver clr)
Constructor for a join set store for RDBMS.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(org.datanucleus.state.DNStateManager sm, E element, int size)
boolean
addAll(org.datanucleus.state.DNStateManager sm, Collection<E> elements, int size)
protected int[]
doInternalAdd(org.datanucleus.state.DNStateManager sm, E element, org.datanucleus.store.connection.ManagedConnection conn, boolean batched, int orderId, boolean executeNow)
ElementIteratorStatement
getIteratorStatement(org.datanucleus.ExecutionContext ec, org.datanucleus.FetchPlan fp, boolean addRestrictionOnOwner)
Method to return the SQLStatement and mapping for an iterator for this backing store.protected int
getNextIDForOrderColumn(org.datanucleus.state.DNStateManager sm)
protected String
getRemoveAllStmt(org.datanucleus.state.DNStateManager sm, Collection elements)
Generate statement for removing a collection of items from the Set.protected String
getRemoveStmt(Object element)
Generate statement for deleting items from the Set.Iterator<E>
iterator(org.datanucleus.state.DNStateManager ownerSM)
Accessor for an iterator through the container elements.boolean
removeAll(org.datanucleus.state.DNStateManager sm, Collection elements, int size)
void
update(org.datanucleus.state.DNStateManager sm, Collection coll)
-
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractSetStore
remove
-
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
contains, 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
-
-
-
-
Constructor Detail
-
JoinSetStore
public JoinSetStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, CollectionTable joinTable, org.datanucleus.ClassLoaderResolver clr)
Constructor for a join set store for RDBMS.- Parameters:
mmd
- Metadata for the member that has the set with join tablejoinTable
- The join tableclr
- The ClassLoaderResolver
-
-
Method Detail
-
update
public void update(org.datanucleus.state.DNStateManager sm, Collection coll)
- Specified by:
update
in interfaceorg.datanucleus.store.types.scostore.CollectionStore<E>
- Overrides:
update
in classAbstractCollectionStore<E>
-
add
public boolean add(org.datanucleus.state.DNStateManager sm, E element, int size)
-
addAll
public boolean addAll(org.datanucleus.state.DNStateManager sm, Collection<E> elements, int size)
-
removeAll
public boolean removeAll(org.datanucleus.state.DNStateManager sm, Collection elements, int size)
-
getRemoveStmt
protected String getRemoveStmt(Object element)
Generate statement for deleting items from the Set. The EMBEDDEDFIELDX is only present when the elements are PC(embedded).DELETE FROM SETTABLE WHERE OWNERCOL=? AND ELEMENTCOL = ? [AND EMBEDDEDFIELD1 = ? AND EMBEDDEDFIELD2 = ? AND EMBEDDEDFIELD3 = ?] [AND RELATION_DISCRIM = ?]
- Overrides:
getRemoveStmt
in classAbstractCollectionStore<E>
- Parameters:
element
- The element to remove- Returns:
- Statement for deleting items from the Set.
-
getRemoveAllStmt
protected String getRemoveAllStmt(org.datanucleus.state.DNStateManager sm, Collection elements)
Generate statement for removing a collection of items from the Set.DELETE FROM SETTABLE WHERE (OWNERCOL=? AND ELEMENTCOL=?) OR (OWNERCOL=? AND ELEMENTCOL=?) OR (OWNERCOL=? AND ELEMENTCOL=?)
- Parameters:
sm
- StateManager for the ownerelements
- Collection of elements to remove- Returns:
- Statement for deleting items from the Set.
-
doInternalAdd
protected int[] doInternalAdd(org.datanucleus.state.DNStateManager sm, E element, org.datanucleus.store.connection.ManagedConnection conn, boolean batched, int orderId, boolean executeNow)
-
getNextIDForOrderColumn
protected int getNextIDForOrderColumn(org.datanucleus.state.DNStateManager sm)
-
iterator
public Iterator<E> iterator(org.datanucleus.state.DNStateManager ownerSM)
Description copied from class:ElementContainerStore
Accessor for an iterator through the container elements.- Specified by:
iterator
in interfaceorg.datanucleus.store.types.scostore.CollectionStore<E>
- Specified by:
iterator
in classAbstractSetStore<E>
- Parameters:
ownerSM
- StateManager for the container.- Returns:
- The Iterator
-
getIteratorStatement
public ElementIteratorStatement getIteratorStatement(org.datanucleus.ExecutionContext ec, org.datanucleus.FetchPlan fp, boolean addRestrictionOnOwner)
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 determining which fields of element to selectaddRestrictionOnOwner
- Whether to restrict to a particular owner (otherwise functions as bulk fetch for many owners).- Returns:
- The SQLStatement and its associated StatementClassMapping
-
-