Class FKArrayStore<E>
- java.lang.Object
-
- org.datanucleus.store.rdbms.scostore.BaseContainerStore
-
- org.datanucleus.store.rdbms.scostore.ElementContainerStore
-
- org.datanucleus.store.rdbms.scostore.AbstractArrayStore<E>
-
- org.datanucleus.store.rdbms.scostore.FKArrayStore<E>
-
- All Implemented Interfaces:
org.datanucleus.store.types.scostore.ArrayStore<E>
,org.datanucleus.store.types.scostore.Store
public class FKArrayStore<E> extends AbstractArrayStore<E>
Implementation of an FK ArrayStore.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
clearNullifyStmt
Statement for nullifying a FK in the element.private java.lang.String
updateFkStmt
Statement for updating a foreign key in a 1-N unidirectional-
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 FKArrayStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear(org.datanucleus.state.DNStateManager ownerSM)
Method to clear the Array.protected java.lang.String
getClearNullifyStmt()
Generates the statement for clearing items by nulling the owner link out.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.private java.lang.String
getUpdateFkStmt()
Generate statement for updating the owner, index columns in an inverse 1-N.java.util.Iterator<E>
iterator(org.datanucleus.state.DNStateManager ownerSM)
Accessor for an iterator through the array elements.boolean
set(org.datanucleus.state.DNStateManager ownerSM, java.lang.Object array)
Method to set the array for the specified owner to the passed value.private boolean
updateElementFk(org.datanucleus.state.DNStateManager ownerSM, E element, java.lang.Object owner, int index)
Update a FK and element position in the element.-
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractArrayStore
add, clearInternal, getArray, internalAdd
-
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, getOwnerMapping, getOwnerMemberMetaData, getRelationType, getStateManagerForEmbeddedPCObject, getStoreManager, isEmbeddedMapping, setOwner
-
-
-
-
Constructor Detail
-
FKArrayStore
public FKArrayStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)
- Parameters:
mmd
- Metadata for the owning field/propertystoreMgr
- Manager for the datastoreclr
- ClassLoader resolver
-
-
Method Detail
-
updateElementFk
private boolean updateElementFk(org.datanucleus.state.DNStateManager ownerSM, E element, java.lang.Object owner, int index)
Update a FK and element position in the element.- Parameters:
ownerSM
- StateManager for the ownerelement
- The element to updateowner
- The owner object to set in the FKindex
- The index position (or -1 if not known)- Returns:
- Whether it was performed successfully
-
getUpdateFkStmt
private java.lang.String getUpdateFkStmt()
Generate statement for updating the owner, index columns in an inverse 1-N. Will result in the statementUPDATE ELEMENTTABLE SET FK_COL_1=?, FK_COL_2=?, FK_IDX=? [,DISTINGUISHER=?] WHERE ELEMENT_ID=?
when we have a single element table, andUPDATE ? SET FK_COL_1=?, FK_COL_2=?, FK_IDX=? [,DISTINGUISHER=?] WHERE ELEMENT_ID=?
when we have multiple element tables possible.- Returns:
- Statement for updating the owner/index of an element in an inverse 1-N
-
clear
public void clear(org.datanucleus.state.DNStateManager ownerSM)
Method to clear the Array. This is called when the container object is being deleted and the elements are to be removed (maybe for dependent field).- Specified by:
clear
in interfaceorg.datanucleus.store.types.scostore.ArrayStore<E>
- Overrides:
clear
in classAbstractArrayStore<E>
- Parameters:
ownerSM
- StateManager
-
getClearNullifyStmt
protected java.lang.String getClearNullifyStmt()
Generates the statement for clearing items by nulling the owner link out. The statement will beUPDATE ARRAYTABLE SET OWNERCOL=NULL, INDEXCOL=NULL [,DISTINGUISHER=NULL] WHERE OWNERCOL=? [AND DISTINGUISHER=?]
when there is only one element table, and will beUPDATE ? SET OWNERCOL=NULL, INDEXCOL=NULL [,DISTINGUISHER=NULL] WHERE OWNERCOL=? [AND DISTINGUISHER=?]
when there is more than 1 element table.- Returns:
- The Statement for clearing items for the owner.
-
set
public boolean set(org.datanucleus.state.DNStateManager ownerSM, java.lang.Object array)
Description copied from class:AbstractArrayStore
Method to set the array for the specified owner to the passed value.- Specified by:
set
in interfaceorg.datanucleus.store.types.scostore.ArrayStore<E>
- Overrides:
set
in classAbstractArrayStore<E>
- Parameters:
ownerSM
- StateManager for the ownerarray
- the array- Returns:
- Whether the array was updated successfully
-
iterator
public java.util.Iterator<E> iterator(org.datanucleus.state.DNStateManager ownerSM)
Description copied from class:AbstractArrayStore
Accessor for an iterator through the array elements.- Specified by:
iterator
in interfaceorg.datanucleus.store.types.scostore.ArrayStore<E>
- Specified by:
iterator
in classAbstractArrayStore<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 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).- Returns:
- The SQLStatement and its associated StatementClassMapping
-
-