org.datanucleus.store.rdbms.scostore
Class RDBMSJoinSetStore

java.lang.Object
  extended by org.datanucleus.store.rdbms.scostore.BaseContainerStore
      extended by org.datanucleus.store.rdbms.scostore.ElementContainerStore
          extended by org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
              extended by org.datanucleus.store.rdbms.scostore.AbstractSetStore
                  extended by org.datanucleus.store.rdbms.scostore.RDBMSJoinSetStore
All Implemented Interfaces:
org.datanucleus.store.scostore.CollectionStore, org.datanucleus.store.scostore.SetStore, org.datanucleus.store.scostore.Store

public class RDBMSJoinSetStore
extends AbstractSetStore

RDBMS-specific implementation of a SetStore using join table.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.rdbms.scostore.ElementContainerStore
ElementContainerStore.ElementInfo
 
Field Summary
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, clr, containerTable, elementInfo, elementIsPersistentInterface, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, emd, iterateUsingDiscriminator, orderMapping, relationDiscriminatorMapping, relationDiscriminatorValue, removeStmt, sizeStmt, usingDiscriminatorInSizeStmt
 
Fields inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowNulls, dba, LOCALISER, ownerMapping, ownerMemberMetaData, relationType, storeMgr
 
Constructor Summary
RDBMSJoinSetStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, CollectionTable joinTable, org.datanucleus.ClassLoaderResolver clr)
          Constructor for a join set store for RDBMS.
 
Method Summary
 boolean add(org.datanucleus.store.ObjectProvider sm, Object element, int size)
          Adds one element to the association owner vs elements.
 boolean addAll(org.datanucleus.store.ObjectProvider sm, Collection elements, int size)
          Adds all elements from a collection to the association container.
protected  int[] doInternalAdd(org.datanucleus.store.ObjectProvider sm, Object element, org.datanucleus.store.connection.ManagedConnection conn, boolean batched, int orderId, boolean executeNow)
           
protected  int getNextIDForOrderColumn(org.datanucleus.store.ObjectProvider sm)
           
protected  String getRemoveAllStmt(org.datanucleus.store.ObjectProvider op, 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.
protected  SQLStatement getSQLStatementForIterator(org.datanucleus.store.ObjectProvider ownerSM)
          Method to generate an SQLStatement for iterating through elements of the set.
 Iterator iterator(org.datanucleus.store.ObjectProvider ownerSM)
          Accessor for an iterator for the set.
 boolean locate(org.datanucleus.store.ObjectProvider sm, Object element)
           
protected  void preGetNextIDForOrderColumn(org.datanucleus.store.connection.ManagedConnection mconn)
           
 boolean removeAll(org.datanucleus.store.ObjectProvider sm, Collection elements, int size)
          Remove all elements from a collection from the association owner vs elements.
protected  boolean removeAllInternal(org.datanucleus.store.ObjectProvider sm, Collection elements, int size)
           
 void update(org.datanucleus.store.ObjectProvider sm, Collection coll)
          Method to update the collection to be the supplied collection of elements.
 
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractSetStore
internalAdd, internalRemove, remove, remove
 
Methods inherited from class org.datanucleus.store.rdbms.scostore.AbstractCollectionStore
contains, containsInternal, getUpdateEmbeddedElementStmt, updateEmbeddedElement, updateEmbeddedElement
 
Methods inherited from class org.datanucleus.store.rdbms.scostore.ElementContainerStore
clear, executeClear, getAddStmt, getClearStmt, getContainerTable, getElementInfo, getElementInformationForClass, getElementMapping, getEmd, getOrderMapping, getRelationDiscriminatorMapping, getRelationDiscriminatorValue, getSize, getSizeStmt, hasOrderMapping, invalidateAddStmt, isElementsAreEmbedded, isElementsAreSerialised, size, validateElementForReading, validateElementForWriting, validateElementType
 
Methods inherited from class org.datanucleus.store.rdbms.scostore.BaseContainerStore
allowsBatching, 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
 
Methods inherited from interface org.datanucleus.store.scostore.CollectionStore
clear, contains, hasOrderMapping, size, updateEmbeddedElement
 
Methods inherited from interface org.datanucleus.store.scostore.Store
getStoreManager
 

Field Detail

locateStmt

protected String locateStmt
Statement to check the existence of an owner-element relation.


maxOrderColumnIdStmt

protected String maxOrderColumnIdStmt
Statement to get the maximum order column id so we can set the next insert value.

Constructor Detail

RDBMSJoinSetStore

public RDBMSJoinSetStore(org.datanucleus.metadata.AbstractMemberMetaData mmd,
                         CollectionTable joinTable,
                         org.datanucleus.ClassLoaderResolver clr)
Constructor for a join set store for RDBMS.

Parameters:
mmd - owner member metadata
joinTable - The join table
clr - The ClassLoaderResolver
Method Detail

update

public void update(org.datanucleus.store.ObjectProvider sm,
                   Collection coll)
Method to update the collection to be the supplied collection of elements.

Specified by:
update in interface org.datanucleus.store.scostore.CollectionStore
Overrides:
update in class AbstractCollectionStore
Parameters:
sm - StateManager of the object
coll - The collection to use

removeAll

public boolean removeAll(org.datanucleus.store.ObjectProvider sm,
                         Collection elements,
                         int size)
Remove all elements from a collection from the association owner vs elements.

Specified by:
removeAll in interface org.datanucleus.store.scostore.CollectionStore
Overrides:
removeAll in class AbstractSetStore
Parameters:
sm - State Manager for the container
elements - Collection of elements to remove
Returns:
Whether the database was updated

add

public boolean add(org.datanucleus.store.ObjectProvider sm,
                   Object element,
                   int size)
Adds one element to the association owner vs elements.

Specified by:
add in interface org.datanucleus.store.scostore.CollectionStore
Overrides:
add in class AbstractSetStore
Parameters:
sm - State Manager for the container.
element - Element to add
Returns:
Whether it was successful

addAll

public boolean addAll(org.datanucleus.store.ObjectProvider sm,
                      Collection elements,
                      int size)
Adds all elements from a collection to the association container.

Specified by:
addAll in interface org.datanucleus.store.scostore.CollectionStore
Overrides:
addAll in class AbstractSetStore
Parameters:
sm - State Manager for the container.
elements - Collection of elements to add
size - Current size of set (if known). Not used by sets
Returns:
Whether it was successful

removeAllInternal

protected boolean removeAllInternal(org.datanucleus.store.ObjectProvider 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 class AbstractCollectionStore
Returns:
Statement for deleting items from the Set.

getRemoveAllStmt

protected String getRemoveAllStmt(org.datanucleus.store.ObjectProvider op,
                                  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:
op - ObjectProvider for the owner
elements - Collection of elements to remove
Returns:
Statement for deleting items from the Set.

locate

public boolean locate(org.datanucleus.store.ObjectProvider sm,
                      Object element)

doInternalAdd

protected int[] doInternalAdd(org.datanucleus.store.ObjectProvider sm,
                              Object element,
                              org.datanucleus.store.connection.ManagedConnection conn,
                              boolean batched,
                              int orderId,
                              boolean executeNow)
                       throws org.datanucleus.store.mapped.exceptions.MappedDatastoreException
Throws:
org.datanucleus.store.mapped.exceptions.MappedDatastoreException

preGetNextIDForOrderColumn

protected void preGetNextIDForOrderColumn(org.datanucleus.store.connection.ManagedConnection mconn)
                                   throws org.datanucleus.store.mapped.exceptions.MappedDatastoreException
Throws:
org.datanucleus.store.mapped.exceptions.MappedDatastoreException

getNextIDForOrderColumn

protected int getNextIDForOrderColumn(org.datanucleus.store.ObjectProvider sm)

iterator

public Iterator iterator(org.datanucleus.store.ObjectProvider ownerSM)
Accessor for an iterator for the set.

Specified by:
iterator in interface org.datanucleus.store.scostore.CollectionStore
Specified by:
iterator in class AbstractSetStore
Parameters:
ownerSM - State Manager for the set.
Returns:
Iterator for the set.

getSQLStatementForIterator

protected SQLStatement getSQLStatementForIterator(org.datanucleus.store.ObjectProvider ownerSM)
Method to generate an SQLStatement for iterating through elements of the set. Selects the join table. Populates the iteratorMappingDef and iteratorMappingParams.

Parameters:
ownerSM - StateManager for the owner object
Returns:
The SQLStatement


Copyright © 2012. All Rights Reserved.