org.jpox.store.rdbms.scostore
Class FKArrayStore

java.lang.Object
  extended byorg.jpox.store.rdbms.scostore.BaseContainerStore
      extended byorg.jpox.store.rdbms.scostore.ElementContainerStore
          extended byorg.jpox.store.rdbms.scostore.AbstractArrayStore
              extended byorg.jpox.store.rdbms.scostore.FKArrayStore
All Implemented Interfaces:
ArrayStore, Store

public class FKArrayStore
extends AbstractArrayStore

Backing store for an array that is formed by a foreign key in the table of the element type. Only supported when the element is a PersistenceCapable type (since that has its own element table, capable of having a FK!)

Version:
$Revision: 1.5 $

Nested Class Summary
 
Nested classes inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore
ElementContainerStore.ElementInfo
 
Field Summary
 
Fields inherited from class org.jpox.store.rdbms.scostore.AbstractArrayStore
addStmt
 
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
FKArrayStore(AbstractPropertyMetaData fmd, RDBMSManager storeMgr, ClassLoaderResolver clr)
          Constructor.
 
Method Summary
 void clear(StateManager ownerSM)
          Method to clear the Array.
protected  java.lang.String getClearNullifyStmt()
          Generates the statement for clearing items by nulling the owner link out.
protected  QueryExpression getIteratorStatement(StateManager ownerSM)
          Accessor for the iterator statement to retrieve the element(s) for the array.
 ScalarExpression joinElementsTo(QueryExpression stmt, QueryExpression parentStmt, JavaTypeMapping ownerMapping, LogicSetExpression ownerTe, DatastoreIdentifier listRangeVar, java.lang.Class filteredElementType, ScalarExpression elmExpr, DatastoreIdentifier elementRangeVar)
          Method used in queries when contains() has been invoked.
 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.jpox.store.rdbms.scostore.AbstractArrayStore
add, getArray, getExistsSubquery, getSizeSubquery, iterator
 
Methods inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore
executeQuery, executeUpdate, getAddStmt, getClearStmt, getElementInformationForClass, getElementType, getOwnerMapping, getSizeStmt, getStateManagerForEmbeddedPCObject, getStoreManager, hasOrderMapping, initialiseStatements, isEmbeddedMapping, 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
 
Methods inherited from interface org.jpox.store.scostore.ArrayStore
getElementType, size
 
Methods inherited from interface org.jpox.store.scostore.Store
getOwnerMapping, getStoreManager
 

Constructor Detail

FKArrayStore

public FKArrayStore(AbstractPropertyMetaData fmd,
                    RDBMSManager storeMgr,
                    ClassLoaderResolver clr)
Constructor.

Parameters:
fmd - Field MetaData for the field that this represents
storeMgr - The Store Manager in use
clr - The ClassLoaderResolver
Method Detail

getClearNullifyStmt

protected java.lang.String getClearNullifyStmt()
Generates the statement for clearing items by nulling the owner link out. The statement will be
 UPDATE ARRAYTABLE SET OWNERCOL=NULL, INDEXCOL=NULL [,DISTINGUISHER=NULL]
 WHERE OWNERCOL=? [AND DISTINGUISHER=?]
 
when there is only one element table, and will be
 UPDATE ? SET OWNERCOL=NULL, INDEXCOL=NULL [,DISTINGUISHER=NULL]
 WHERE OWNERCOL=? [AND DISTINGUISHER=?]
 
when there is more than 1 element table.

Returns:
The Statement for clearing items for the owner.

clear

public void clear(StateManager ownerSM)
Method to clear the Array. This is called when the container object is being deleted and the elements are to be removed (maybe for dependent field).

Specified by:
clear in interface ArrayStore
Overrides:
clear in class AbstractArrayStore
Parameters:
ownerSM - The state manager

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
Overrides:
set in class AbstractArrayStore
Parameters:
ownerSM - State Manager for the owner
array - the array
Returns:
Whether the array was updated successfully

getIteratorStatement

protected QueryExpression getIteratorStatement(StateManager ownerSM)
Accessor for the iterator statement to retrieve the element(s) for the array.

Specified by:
getIteratorStatement in class AbstractArrayStore
Parameters:
ownerSM - The StateManager
Returns:
The Query Statement.

joinElementsTo

public ScalarExpression joinElementsTo(QueryExpression stmt,
                                       QueryExpression parentStmt,
                                       JavaTypeMapping ownerMapping,
                                       LogicSetExpression ownerTe,
                                       DatastoreIdentifier listRangeVar,
                                       java.lang.Class filteredElementType,
                                       ScalarExpression elmExpr,
                                       DatastoreIdentifier elementRangeVar)
Method used in queries when contains() has been invoked.

Parameters:
stmt - The Query Statement
parentStmt - the parent Query Statement. If there is no parent, parentStmt must be equals to stmt
ownerMapping - the mapping for the owner.
ownerTe - Table Expression for the owner
listRangeVar - The range variable for the "List" table.
filteredElementType - The Class Type for the filtered element
elmExpr - The Expression for the element
elementRangeVar - The SQL alias, or "range variable", to assign to the expression or to the element table.
Returns:
expression to the join


Copyright © -2007 . All Rights Reserved.