org.datanucleus.store.mapped.scostore
Class AbstractArrayStore

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.AbstractArrayStore
All Implemented Interfaces:
ArrayStoreQueryable, ArrayStore, Store
Direct Known Subclasses:
FKArrayStore, JoinArrayStore

public abstract class AbstractArrayStore
extends ElementContainerStore
implements ArrayStore, ArrayStoreQueryable

Abstract representation of the backing store for an array.


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 AbstractArrayStore(StoreManager storeMgr, ClassLoaderResolver clr, AbstractArrayStoreSpecialization specialization)
          Constructor.
 
Method Summary
 boolean add(StateManager sm, java.lang.Object element, int position)
          Adds one element to the association owner vs elements
 void clear(StateManager ownerSM)
          Clear the association from owner to all elements.
 java.util.List getArray(StateManager ownerSM)
          Accessor for the array from the datastore.
 QueryExpression getExistsSubquery(QueryExpression qs, JavaTypeMapping mapping, LogicSetExpression ownerTe, DatastoreIdentifier arrayTableAlias)
          Query utility to generate an exists() statement for an element.
 QueryExpression getSizeSubquery(QueryExpression qs, JavaTypeMapping mapping, LogicSetExpression ownerTe, DatastoreIdentifier arrayTableAlias)
          Query utility to generate a subquery for the size() of the collection.
abstract  java.util.Iterator iterator(StateManager ownerSM)
          Accessor for an iterator through the array elements.
 boolean set(StateManager ownerSM, java.lang.Object array)
          Method to set the array for the specified owner to the passed value.
 
Methods inherited from class org.datanucleus.store.mapped.scostore.ElementContainerStore
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, 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.ArrayStore
getElementType, size
 
Methods inherited from interface org.datanucleus.store.scostore.Store
getStoreManager
 
Methods inherited from interface org.datanucleus.store.mapped.expression.ArrayStoreQueryable
joinElementsTo
 

Constructor Detail

AbstractArrayStore

protected AbstractArrayStore(StoreManager storeMgr,
                             ClassLoaderResolver clr,
                             AbstractArrayStoreSpecialization specialization)
Constructor.

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

getArray

public java.util.List getArray(StateManager ownerSM)
Accessor for the array from the datastore.

Specified by:
getArray in interface ArrayStore
Parameters:
ownerSM - SM for the owner
Returns:
The array (as a List of objects)

clear

public void clear(StateManager ownerSM)
Clear the association from owner to all elements. Observes the necessary dependent field settings with respect to whether it should delete the element when doing so.

Specified by:
clear in interface ArrayStore
Overrides:
clear in class ElementContainerStore
Parameters:
ownerSM - State Manager for the container.

set

public boolean set(StateManager ownerSM,
                   java.lang.Object array)
Method to set the array for the specified owner to the passed value.

Specified by:
set in interface ArrayStore
Parameters:
ownerSM - State Manager for the owner
array - the array
Returns:
Whether the array was updated successfully

add

public boolean add(StateManager sm,
                   java.lang.Object element,
                   int position)
Adds one element to the association owner vs elements

Parameters:
sm - State Manager for the container
element - The element to add
position - The position to add this element at
Returns:
Whether it was successful

iterator

public abstract java.util.Iterator iterator(StateManager ownerSM)
Accessor for an iterator through the array elements.

Specified by:
iterator in interface ArrayStore
Specified by:
iterator in class ElementContainerStore
Parameters:
ownerSM - State Manager for the container.
Returns:
The Iterator

getExistsSubquery

public QueryExpression getExistsSubquery(QueryExpression qs,
                                         JavaTypeMapping mapping,
                                         LogicSetExpression ownerTe,
                                         DatastoreIdentifier arrayTableAlias)
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 ArrayStoreQueryable
Parameters:
qs - The JDOQL query statement
mapping - mapping of the field
ownerTe - Expression for the table
arrayTableAlias - alias for the array
Returns:
The JDOQL query statement

getSizeSubquery

public QueryExpression getSizeSubquery(QueryExpression qs,
                                       JavaTypeMapping mapping,
                                       LogicSetExpression ownerTe,
                                       DatastoreIdentifier arrayTableAlias)
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 ArrayStoreQueryable
Parameters:
qs - The query statement
mapping - mapping of the field
ownerTe - Expression for the table
arrayTableAlias - alias for the array
Returns:
The query statement


Copyright © 2010. All Rights Reserved.