org.datanucleus.store.mapped.scostore
Class AbstractCollectionStore

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
All Implemented Interfaces:
CollectionStoreQueryable, CollectionStore, Store
Direct Known Subclasses:
AbstractListStore, AbstractSetStore

public abstract class AbstractCollectionStore
extends ElementContainerStore
implements CollectionStore, CollectionStoreQueryable

Abstract representation of a store of a Collection. Contains all common parts of storing Sets and Lists.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.mapped.scostore.ElementContainerStore
ElementContainerStore.ElementInfo
 
Field Summary
 
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
protected AbstractCollectionStore(StoreManager storeMgr, ClassLoaderResolver clr, AbstractCollectionStoreSpecialization abstractCollectionStoreSpecialization)
          Constructor.
 
Method Summary
 boolean contains(StateManager sm, java.lang.Object element)
          Method to verify if the association owner vs elements contains a specific element in the association
 QueryExpression getExistsSubquery(QueryExpression qs, JavaTypeMapping mapping, LogicSetExpression ownerTe, DatastoreIdentifier collectionTableAlias)
          Query utility to generate an exists() statement for an element.
 QueryExpression getSizeSubquery(QueryExpression qs, JavaTypeMapping mapping, LogicSetExpression ownerTe, DatastoreIdentifier collectionTableAlias)
          Query utility to generate a subquery for the size() of the collection.
 void update(StateManager sm, java.util.Collection coll)
          Method to update the collection to be the supplied collection of elements.
 boolean updateEmbeddedElement(StateManager sm, java.lang.Object element, int fieldNumber, java.lang.Object value)
          Method to update a field of an embedded element.
 
Methods inherited from class org.datanucleus.store.mapped.scostore.ElementContainerStore
clear, getContainerTable, getElementInfo, getElementInformationForClass, getElementMapping, getElementType, getEmd, getOrderMapping, getRelationDiscriminatorMapping, getRelationDiscriminatorValue, hasOrderMapping, isElementsAreEmbedded, isElementsAreSerialised, iterator, size, validateElementForReading, validateElementForWriting, validateElementType
 
Methods inherited from class org.datanucleus.store.mapped.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
add, addAll, clear, getElementType, hasOrderMapping, iterator, remove, removeAll, size
 
Methods inherited from interface org.datanucleus.store.scostore.Store
getStoreManager
 
Methods inherited from interface org.datanucleus.store.mapped.expression.CollectionStoreQueryable
joinElementsTo
 

Constructor Detail

AbstractCollectionStore

protected AbstractCollectionStore(StoreManager storeMgr,
                                  ClassLoaderResolver clr,
                                  AbstractCollectionStoreSpecialization abstractCollectionStoreSpecialization)
Constructor.

Parameters:
storeMgr - Manager for the store
clr - ClassLoader resolver
Method Detail

updateEmbeddedElement

public boolean updateEmbeddedElement(StateManager sm,
                                     java.lang.Object element,
                                     int fieldNumber,
                                     java.lang.Object value)
Method to update a field of an embedded element.

Specified by:
updateEmbeddedElement in interface CollectionStore
Parameters:
sm - State Manager of the owner
element - The element to update
fieldNumber - The number of the field to update
value - The value
Returns:
true if the datastore was updated

update

public void update(StateManager sm,
                   java.util.Collection coll)
Method to update the collection to be the supplied collection of elements.

Specified by:
update in interface CollectionStore
Parameters:
sm - StateManager of the object
coll - The collection to use

contains

public boolean contains(StateManager sm,
                        java.lang.Object element)
Method to verify if the association owner vs elements contains a specific element in the association

Specified by:
contains in interface CollectionStore
Parameters:
sm - The StateManager
element - The element
Returns:
Whether it contains the element

getExistsSubquery

public QueryExpression getExistsSubquery(QueryExpression qs,
                                         JavaTypeMapping mapping,
                                         LogicSetExpression ownerTe,
                                         DatastoreIdentifier collectionTableAlias)
Query utility to generate an exists() statement for an element. The generated query will be of the form
 SELECT 1 FROM JOINTABLE THIS_JOIN WHERE THIS_JOIN.OWNER_ID_OID = THIS.OWNER_ID
 

Specified by:
getExistsSubquery in interface CollectionStoreQueryable
Parameters:
qs - The parent query statement that will use this as a subquery
mapping - mapping for the owner
ownerTe - Expression for the table that the subquery should join to
collectionTableAlias - alias for the main table of the subquery
Returns:
The query statement

getSizeSubquery

public QueryExpression getSizeSubquery(QueryExpression qs,
                                       JavaTypeMapping mapping,
                                       LogicSetExpression ownerTe,
                                       DatastoreIdentifier collectionTableAlias)
Query utility to generate a subquery for the size() of the collection. The generated query will be of the form
 SELECT COUNT(*) FROM JOINTABLE THIS_JOIN WHERE THIS_JOIN.OWNER_ID_OID = THIS.OWNER_ID
 

Specified by:
getSizeSubquery in interface CollectionStoreQueryable
Parameters:
qs - The parent query statement that will use this as a subquery
mapping - mapping of the field
ownerTe - Expression for the owner table that the subquery should join to
collectionTableAlias - alias for the main table of the subquery
Returns:
The query statement


Copyright © 2010. All Rights Reserved.