Class FKSetStore<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.FKSetStore<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 FKSetStore<E> extends AbstractSetStore<E>
RDBMS-specific implementation of anSetStoreusing foreign keys.
-
-
Field Summary
-
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 FKSetStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)Constructor for the backing store of a FK set for RDBMS.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(org.datanucleus.state.ObjectProvider ownerOP, E element, int size)Method to add an object to the relationship at the collection end.booleanaddAll(org.datanucleus.state.ObjectProvider ownerOP, Collection<E> elements, int size)Method to add a collection of object to the relationship at the collection end.protected booleancheckRemovalOfElementShouldDelete(org.datanucleus.state.ObjectProvider ownerOP)Convenience method to return if the removal of an element should delete the element.voidclear(org.datanucleus.state.ObjectProvider ownerOP)Method to allow the Set relationship to be cleared out.protected StringgetClearNullifyStmt(ComponentInfo info)Generates the statement for clearing items by nulling the owner link out.protected intgetFieldNumberInElementForBidirectional(org.datanucleus.state.ObjectProvider op)This seems to return the field number in the element of the relation when it is a bidirectional relation.ElementIteratorStatementgetIteratorStatement(org.datanucleus.ExecutionContext ec, org.datanucleus.FetchPlan fp, boolean addRestrictionOnOwner)Method to return the SQLStatement and mapping for an iterator for this backing store.Iterator<E>iterator(org.datanucleus.state.ObjectProvider ownerOP)Accessor for an iterator for the set.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.booleanremove(org.datanucleus.state.ObjectProvider ownerOP, Object element, int size, boolean allowDependentField)Method to remove the link to the collection object specified.booleanremoveAll(org.datanucleus.state.ObjectProvider ownerOP, Collection elements, int size)Method to remove the links to a collection of elements specified.voidupdate(org.datanucleus.state.ObjectProvider ownerOP, Collection coll)Method to update the collection to be the supplied collection of elements.-
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
-
FKSetStore
public FKSetStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)Constructor for the backing store of a FK set for RDBMS.- Parameters:
mmd- The MetaData for the field that this representsstoreMgr- The StoreManager managing the associated datastore.clr- The ClassLoaderResolver
-
-
Method Detail
-
getFieldNumberInElementForBidirectional
protected int getFieldNumberInElementForBidirectional(org.datanucleus.state.ObjectProvider op)
This seems to return the field number in the element of the relation when it is a bidirectional relation.- Parameters:
op- ObjectProvider for the owner.- Returns:
- The field number in the element for this relation
-
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 owner.coll- The collection to use
-
add
public boolean add(org.datanucleus.state.ObjectProvider ownerOP, E element, int size)Method to add an object to the relationship at the collection end.- Parameters:
ownerOP- ObjectProvider for the owner.element- Element to be added- Returns:
- Success indicator
-
addAll
public boolean addAll(org.datanucleus.state.ObjectProvider ownerOP, Collection<E> elements, int size)Method to add a collection of object to the relationship at the collection end.- Parameters:
ownerOP- ObjectProvider for the owner.elements- Elements to be added- Returns:
- Success indicator
-
remove
public boolean remove(org.datanucleus.state.ObjectProvider ownerOP, Object element, int size, boolean allowDependentField)Method to remove the link to the collection object specified. Depending on the column characteristics in the collection table, the id of the owner field may be NULLed, or the record may be deleted completely (as per cascade-delete in EJB).- Specified by:
removein interfaceorg.datanucleus.store.types.scostore.CollectionStore<E>- Overrides:
removein classAbstractSetStore<E>- Parameters:
ownerOP- ObjectProvider for the owner.element- The element of the collection to be deleted.allowDependentField- Whether to allow any cascade deletes caused by this removalsize- Current size- Returns:
- A success indicator.
-
removeAll
public boolean removeAll(org.datanucleus.state.ObjectProvider ownerOP, Collection elements, int size)Method to remove the links to a collection of elements specified. Depending on the column characteristics in the collection table, the id of the owner fields may be NULLed, or the records may be deleted completely.- Specified by:
removeAllin interfaceorg.datanucleus.store.types.scostore.CollectionStore<E>- Overrides:
removeAllin classAbstractSetStore<E>- Parameters:
ownerOP- ObjectProvider for the owner.elements- The elements of the collection to be deleted.- Returns:
- A success indicator.
-
checkRemovalOfElementShouldDelete
protected boolean checkRemovalOfElementShouldDelete(org.datanucleus.state.ObjectProvider ownerOP)
Convenience method to return if the removal of an element should delete the element.- Parameters:
ownerOP- ObjectProvider for the owner.- Returns:
- Whether we should delete the element on removing from the collection
-
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 owner.element- The element
-
clear
public void clear(org.datanucleus.state.ObjectProvider ownerOP)
Method to allow the Set relationship to be cleared out. 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.
-
getClearNullifyStmt
protected String getClearNullifyStmt(ComponentInfo info)
Generates the statement for clearing items by nulling the owner link out. The statement will be of the formUPDATE LISTTABLE SET OWNERCOL=NULL [,DISTINGUISHER=NULL] WHERE OWNERCOL=?
- Parameters:
info- ElementInfo for the element- Returns:
- The Statement for clearing items for the owner.
-
iterator
public Iterator<E> iterator(org.datanucleus.state.ObjectProvider ownerOP)
Accessor for an iterator for the set.- Specified by:
iteratorin interfaceorg.datanucleus.store.types.scostore.CollectionStore<E>- Specified by:
iteratorin classAbstractSetStore<E>- Parameters:
ownerOP- ObjectProvider for the owner.- Returns:
- Iterator for the set.
-
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 ELEM_TBL [WHERE] [ELEM_TBL.OWNER_ID = {value}] [AND] [ELEM_TBL.DISCRIM = {discrimValue}] [ORDER BY {orderClause}]- 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
-
-