org.jpox.store.rdbms.scostore
Class AbstractCollectionStore

java.lang.Object
  extended byorg.jpox.store.rdbms.scostore.BaseContainerStore
      extended byorg.jpox.store.rdbms.scostore.ElementContainerStore
          extended byorg.jpox.store.rdbms.scostore.AbstractCollectionStore
Direct Known Subclasses:
org.jpox.store.rdbms.scostore.AbstractListStore, org.jpox.store.rdbms.scostore.AbstractSetStore

public abstract class AbstractCollectionStore
extends ElementContainerStore

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

Version:
$Revision: 1.44 $

Nested Class Summary
 
Nested classes inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore
ElementContainerStore.ElementInfo
 
Field Summary
protected  java.lang.String containsStmt
          Statement for getting whether an element is contained in the collection.
 
Fields inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore
clearStmt, clr, containerTable, dba, elementInfo, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, elmIdentifier, emd, iterateUsingDiscriminator, LOCALISER, orderMapping, ownerFieldMetaData, ownerMapping, relationDiscriminatorMapping, relationDiscriminatorValue, sizeStmt, storeMgr, thisIdentifier
 
Constructor Summary
protected AbstractCollectionStore(StoreManager storeMgr, ClassLoaderResolver clr)
          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
protected  java.lang.String getContainsStmt()
          Generate statement for retrieving the contents of the Collection.
 QueryExpression getExistsSubquery(QueryExpression qs, JavaTypeMapping mapping, LogicSetExpression ownerTe, DatastoreIdentifier collectionRangeVar)
          JDOQL utility to generate an exists() statement for an element.
 QueryExpression getSizeSubquery(QueryExpression qs, JavaTypeMapping mapping, LogicSetExpression ownerTe, DatastoreIdentifier collectionRangeVar)
          JDOQL utility to generate a subquery for the size() of the collection.
protected  java.lang.String getUpdateEmbeddedElementStmt(JavaTypeMapping fieldMapping)
          Generate statement for update the field of an embedded element.
protected  void initialiseStatements()
          Method to initialise the statements being used.
 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.jpox.store.rdbms.scostore.ElementContainerStore
clear, executeQuery, executeUpdate, getAddStmt, getClearStmt, getElementInformationForClass, getElementType, getOwnerMapping, getSizeStmt, getStateManagerForEmbeddedPCObject, getStoreManager, hasOrderMapping, isEmbeddedMapping, iterator, newResultObjectFactory, populateElementDiscriminatorInStatement, populateElementInStatement, populateEmbeddedElementFieldsInStatement, populateOrderInStatement, populateOwnerInStatement, populateRelationDiscriminatorInStatement, size, validateElementForReading, validateElementForWriting, validateElementType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

containsStmt

protected java.lang.String containsStmt
Statement for getting whether an element is contained in the collection.

Constructor Detail

AbstractCollectionStore

protected AbstractCollectionStore(StoreManager storeMgr,
                                  ClassLoaderResolver clr)
Constructor.

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

initialiseStatements

protected void initialiseStatements()
Method to initialise the statements being used.

Overrides:
initialiseStatements in class ElementContainerStore

getUpdateEmbeddedElementStmt

protected java.lang.String getUpdateEmbeddedElementStmt(JavaTypeMapping fieldMapping)
Generate statement for update the field of an embedded element.
 UPDATE SETTABLE
 SET EMBEDDEDFIELD1 = ?
 WHERE OWNERCOL=?
 AND ELEMENTCOL = ?
 

Parameters:
fieldMapping - The mapping for the field within the embedded object to be updated
Returns:
Statement for updating an embedded element in the Set

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.

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

getContainsStmt

protected java.lang.String getContainsStmt()
Generate statement for retrieving the contents of the Collection. The discriminator part is only present when the element type has inheritance strategy of "superclass-table" and is Inverse.
 SELECT OWNERCOL FROM COLLECTIONTABLE 
 WHERE OWNERCOL=?
 AND ELEMENTCOL=?
 [AND DISCRIMINATOR=?]
 [AND RELATION_DISCRIM=?]
 

Returns:
Statement for retrieving the contents of the Collection.

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

Parameters:
sm - The StateManager
element - The element
Returns:
Whether it contains the element

getExistsSubquery

public QueryExpression getExistsSubquery(QueryExpression qs,
                                         JavaTypeMapping mapping,
                                         LogicSetExpression ownerTe,
                                         DatastoreIdentifier collectionRangeVar)
JDOQL 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
 

Parameters:
qs - The JDOQL query statement
mapping - mapping of the field
ownerTe - Expression for the table
collectionRangeVar - range variable for the collection
Returns:
The JDOQL query statement

getSizeSubquery

public QueryExpression getSizeSubquery(QueryExpression qs,
                                       JavaTypeMapping mapping,
                                       LogicSetExpression ownerTe,
                                       DatastoreIdentifier collectionRangeVar)
JDOQL 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
 

Parameters:
qs - The JDOQL query statement
mapping - mapping of the field
ownerTe - Expression for the table
collectionRangeVar - range variable for the collection
Returns:
The JDOQL query statement


Copyright © -2007 . All Rights Reserved.