org.datanucleus.store.rdbms.scostore
Class RDBMSJoinSetStore

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

public class RDBMSJoinSetStore
extends org.datanucleus.store.mapped.scostore.JoinSetStore

RDBMS-specific implementation of a JoinSetStore.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.mapped.scostore.ElementContainerStore
org.datanucleus.store.mapped.scostore.ElementContainerStore.ElementInfo
 
Field Summary
protected  java.lang.String locateStmt
          Statement to check the existence of an owner-element relation.
protected  java.lang.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.mapped.scostore.ElementContainerStore
clr, containerTable, elementInfo, elementIsPersistentInterface, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, emd, iterateUsingDiscriminator, orderMapping, relationDiscriminatorMapping, relationDiscriminatorValue, specialization
 
Fields inherited from class org.datanucleus.store.mapped.scostore.BaseContainerStore
allowsNull, 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
protected  int[] doInternalAdd(org.datanucleus.StateManager sm, java.lang.Object element, org.datanucleus.ManagedConnection conn, boolean batched, int orderId, boolean executeNow)
           
protected  int getNextIDForOrderColumn(org.datanucleus.StateManager sm)
           
protected  java.lang.String getRemoveAllStmt(org.datanucleus.StateManager ownerSm, java.util.Collection elements)
          Generate statement for removing a collection of items from the Set.
protected  java.lang.String getRemoveStmt()
          Generate statement for deleting items from the Set.
protected  SQLStatement getSQLStatementForIterator(org.datanucleus.StateManager ownerSM)
          Method to generate an SQLStatement for iterating through elements of the set.
 java.util.Iterator iterator(org.datanucleus.StateManager ownerSM)
          Accessor for an iterator for the set.
 boolean locate(org.datanucleus.StateManager sm, java.lang.Object element)
           
protected  void preGetNextIDForOrderColumn(org.datanucleus.ManagedConnection mconn)
           
protected  boolean removeAllInternal(org.datanucleus.StateManager sm, java.util.Collection elements, int size)
           
 
Methods inherited from class org.datanucleus.store.mapped.scostore.JoinSetStore
add, addAll, joinElementsTo, removeAll, update
 
Methods inherited from class org.datanucleus.store.mapped.scostore.AbstractSetStore
remove
 
Methods inherited from class org.datanucleus.store.mapped.scostore.AbstractCollectionStore
contains, getExistsSubquery, getSizeSubquery, updateEmbeddedElement
 
Methods inherited from class org.datanucleus.store.mapped.scostore.ElementContainerStore
clear, getContainerTable, getElementInfo, getElementInformationForClass, getElementMapping, getElementType, getEmd, getOrderMapping, getRelationDiscriminatorMapping, getRelationDiscriminatorValue, hasOrderMapping, isElementsAreEmbedded, isElementsAreSerialised, size, validateElementForReading, validateElementForWriting, validateElementType
 
Methods inherited from class org.datanucleus.store.mapped.scostore.BaseContainerStore
allowsBatching, getDatastoreAdapter, getOwnerMapping, getOwnerMemberMetaData, getRelationType, getStateManagerForEmbeddedPCObject, 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, getElementType, hasOrderMapping, size, updateEmbeddedElement
 
Methods inherited from interface org.datanucleus.store.scostore.Store
getStoreManager
 

Field Detail

locateStmt

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


maxOrderColumnIdStmt

protected java.lang.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

removeAllInternal

protected boolean removeAllInternal(org.datanucleus.StateManager sm,
                                    java.util.Collection elements,
                                    int size)
Specified by:
removeAllInternal in class org.datanucleus.store.mapped.scostore.JoinSetStore

getRemoveStmt

protected java.lang.String getRemoveStmt()
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 = ?]
 

Returns:
Statement for deleting items from the Set.

getRemoveAllStmt

protected java.lang.String getRemoveAllStmt(org.datanucleus.StateManager ownerSm,
                                            java.util.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:
ownerSm - The owner StateManager
elements - Collection of elements to remove
Returns:
Statement for deleting items from the Set.

locate

public boolean locate(org.datanucleus.StateManager sm,
                      java.lang.Object element)
Specified by:
locate in class org.datanucleus.store.mapped.scostore.JoinSetStore

doInternalAdd

protected int[] doInternalAdd(org.datanucleus.StateManager sm,
                              java.lang.Object element,
                              org.datanucleus.ManagedConnection conn,
                              boolean batched,
                              int orderId,
                              boolean executeNow)
                       throws org.datanucleus.store.mapped.exceptions.MappedDatastoreException
Specified by:
doInternalAdd in class org.datanucleus.store.mapped.scostore.JoinSetStore
Throws:
org.datanucleus.store.mapped.exceptions.MappedDatastoreException

preGetNextIDForOrderColumn

protected void preGetNextIDForOrderColumn(org.datanucleus.ManagedConnection mconn)
                                   throws org.datanucleus.store.mapped.exceptions.MappedDatastoreException
Specified by:
preGetNextIDForOrderColumn in class org.datanucleus.store.mapped.scostore.JoinSetStore
Throws:
org.datanucleus.store.mapped.exceptions.MappedDatastoreException

getNextIDForOrderColumn

protected int getNextIDForOrderColumn(org.datanucleus.StateManager sm)
Specified by:
getNextIDForOrderColumn in class org.datanucleus.store.mapped.scostore.JoinSetStore

iterator

public java.util.Iterator iterator(org.datanucleus.StateManager ownerSM)
Accessor for an iterator for the set.

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

getSQLStatementForIterator

protected SQLStatement getSQLStatementForIterator(org.datanucleus.StateManager 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 © 2009. All Rights Reserved.