org.jpox.store.mapped
Class MappedStoreManager

java.lang.Object
  extended by org.jpox.store.AbstractStoreManager
      extended by org.jpox.store.mapped.MappedStoreManager
All Implemented Interfaces:
StoreManager

public abstract class MappedStoreManager
extends AbstractStoreManager

Manager for a datastore that has a schema and maps classes to associated objects in the datastore. Datastores such as RDBMS will extend this type of StoreManager.

In a "mapped" datastore, a class is associated with a DatastoreClass. Similarly a field of a class is associated with a DatastoreField. Where a relation is stored separately this is associated with a DatastoreContainerObject. In an RDBMS datastore this will be

This type of StoreManager allows creation/validation of the schema. A schema is split into "tables", "columns", "constraints" currently. The PMF/EMF allows specification of a set of properties that will apply to this type of datastore.

Version:
$Revision: 1.11 $

Field Summary
protected  boolean autoCreateColumns
          Whether to auto create any columns that are missing.
protected  boolean autoCreateConstraints
          Whether to auto create any constraints
protected  boolean autoCreateTables
          Whether to auto create any tables.
protected  boolean autoCreateWarnOnError
          Whether to warn only when any errors occur on auto-create.
protected  java.util.Map datastoreContainerByIdentifier
          Map of all managed datastore containers (tables) keyed by the datastore identifier.
protected  DatastoreAdapter dba
          Adapter for the datastore being used.
protected  IdentifierFactory identifierFactory
          Factory for identifiers for this datastore.
protected  boolean validateColumns
          Whether to validate any columns
protected  boolean validateConstraints
          Whether to validate any constraints
protected  boolean validateTables
          Whether to validate any tables
 
Fields inherited from class org.jpox.store.AbstractStoreManager
autoStartMechanism, fixedDatastore, LOCALISER, nontxConnectionFactoryName, omfContext, persistenceHandler, poidManager, readOnlyDatastore, readOnlyDatastoreAction, schemaHandler, starter, starterInitialised, storeDataMgr, storeManagerKey, storeManagerRuntime, txConnectionFactoryName
 
Constructor Summary
protected MappedStoreManager(java.lang.String key, ClassLoaderResolver clr, OMFContext omfContext)
          Constructor.
 
Method Summary
 void addDatastoreContainer(DatastoreContainerObject table)
          Method to add a datastore container to the managed datastore classes
 void close()
          Release of resources.
abstract  void createDatastoreColumnsForFieldUsingSubclassTable(JavaTypeMapping m, DatastoreContainerObject table, AbstractMemberMetaData fmd, ClassLoaderResolver clr)
          Method to create the necessary datastore columns for a field using subclass-table inheritance.
abstract  void createDatastoreColumnsForReferenceField(JavaTypeMapping m, DatastoreContainerObject table, AbstractMemberMetaData fmd, ClassLoaderResolver clr, boolean embedded)
          Method to create the necessary datastore columns for a reference field.
 AbstractClassMetaData[] getClassesManagingTableForClass(AbstractClassMetaData cmd, ClassLoaderResolver clr)
          Method to return the class(es) that has a table managing the persistence of the fields of the supplied class.
 AbstractClassMetaData getClassWithPrimaryKeyForClass(AbstractClassMetaData cmd, ClassLoaderResolver clr)
          Utility to navigate the inheritance hierarchy to find the base class that defines the primary keys for this tree.
 DatastoreAdapter getDatastoreAdapter()
          Gets the DatastoreAdapter to use for this store.
 DatastoreClass getDatastoreClass(DatastoreIdentifier name)
          Returns the JDO table having the given SQL identifier.
 DatastoreClass getDatastoreClass(java.lang.String className, ClassLoaderResolver clr)
          Returns the primary datastore container serving as backing for the given class.
 DatastoreContainerObject getDatastoreContainerObject(AbstractMemberMetaData fmd)
          Returns the datastore container (table) for the specified field.
abstract  FetchStatement getFetchStatement(DatastoreContainerObject table)
          Method to create a new fetch statement for the passed table.
abstract  FieldManager getFieldManagerForResultProcessing(StateManager sm, java.lang.Object rs, StatementExpressionIndex[] stmtExprIndx)
          Accessor for a FieldManager capable of processing the results of a query.
 IdentifierFactory getIdentifierFactory()
           
 MappingManager getMappingManager()
          Gets the MappingManager to use for this store.
 StoreData[] getStoreDataForDatastoreContainerObject(DatastoreIdentifier tableIdentifier)
          Utility to return all StoreData for a Datastore Container identifier.
abstract  DatastoreContainerObject newJoinDatastoreContainerObject(AbstractMemberMetaData fmd, ClassLoaderResolver clr)
          Called by Mapping objects to request the creation of a DatastoreObject (table).
 boolean supportsValueStrategy(java.lang.String strategy)
          Accessor for whether this value strategy is supported.
 
Methods inherited from class org.jpox.store.AbstractStoreManager
addClass, addClasses, addClasses, clearAutoStarter, deregisterAllStoreData, getApiAdapter, getAutoStartMechanism, getBackingStoreForField, getClassNameForObjectID, getConnection, getDatastoreDate, getExtent, getJPOXConnection, getJPOXSequence, getMetaDataManager, getOMFContext, getPersistenceHandler, getPoidManager, getPropertiesForGenerator, getRuntimeManager, getSchemaHandler, getStoreManagerKey, getStrategyForNative, getStrategyValue, getStrategyValueForGenerator, getSubClassesForClass, getSupportedOptions, initialiseAutoStart, isStrategyDatastoreAttributed, manageClassForIdentity, managesClass, notifyObjectIsOutdated, outputDatastoreInformation, outputSchemaInformation, performVersionCheck, registerStoreData, removeAllClasses, supportsQueryLanguage, usesDatastoreClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dba

protected DatastoreAdapter dba
Adapter for the datastore being used.


identifierFactory

protected IdentifierFactory identifierFactory
Factory for identifiers for this datastore. Really should be on MappedStoreManager.


autoCreateTables

protected final boolean autoCreateTables
Whether to auto create any tables.


autoCreateColumns

protected final boolean autoCreateColumns
Whether to auto create any columns that are missing.


autoCreateConstraints

protected final boolean autoCreateConstraints
Whether to auto create any constraints


autoCreateWarnOnError

protected final boolean autoCreateWarnOnError
Whether to warn only when any errors occur on auto-create.


validateTables

protected final boolean validateTables
Whether to validate any tables


validateColumns

protected final boolean validateColumns
Whether to validate any columns


validateConstraints

protected final boolean validateConstraints
Whether to validate any constraints


datastoreContainerByIdentifier

protected java.util.Map datastoreContainerByIdentifier
Map of all managed datastore containers (tables) keyed by the datastore identifier. Only currently used for storing SequenceTable.

Constructor Detail

MappedStoreManager

protected MappedStoreManager(java.lang.String key,
                             ClassLoaderResolver clr,
                             OMFContext omfContext)
Constructor. Stores the basic information required for the datastore management.

Parameters:
key - Key for this StoreManager
clr - the ClassLoaderResolver
omfContext - The corresponding ObjectManagerFactory context.
See Also:
StoreManagerFactory
Method Detail

close

public void close()
Description copied from interface: StoreManager
Release of resources.

Specified by:
close in interface StoreManager
Overrides:
close in class AbstractStoreManager

supportsValueStrategy

public boolean supportsValueStrategy(java.lang.String strategy)
Accessor for whether this value strategy is supported. Overrides the setting in the superclass for identity/sequence if the adapter doesnt support them.

Specified by:
supportsValueStrategy in interface StoreManager
Overrides:
supportsValueStrategy in class AbstractStoreManager
Parameters:
strategy - The strategy
Returns:
Whether it is supported.

getIdentifierFactory

public IdentifierFactory getIdentifierFactory()

getDatastoreAdapter

public DatastoreAdapter getDatastoreAdapter()
Gets the DatastoreAdapter to use for this store.

Returns:
Returns the DatastoreAdapter

getMappingManager

public MappingManager getMappingManager()
Gets the MappingManager to use for this store.

Returns:
Returns the MappingManager.

getFetchStatement

public abstract FetchStatement getFetchStatement(DatastoreContainerObject table)
Method to create a new fetch statement for the passed table.

Parameters:
table - The table to fetch from
Returns:
The fetch statement

newJoinDatastoreContainerObject

public abstract DatastoreContainerObject newJoinDatastoreContainerObject(AbstractMemberMetaData fmd,
                                                                         ClassLoaderResolver clr)
Called by Mapping objects to request the creation of a DatastoreObject (table).

Parameters:
fmd - The field metadata describing the field.
clr - The ClassLoaderResolver
Returns:
The DatastoreContainerObject

getStoreDataForDatastoreContainerObject

public StoreData[] getStoreDataForDatastoreContainerObject(DatastoreIdentifier tableIdentifier)
Utility to return all StoreData for a Datastore Container identifier. Returns StoreData with this table identifier and where the class is the owner of the table.

Parameters:
tableIdentifier - Identifier for the table
Returns:
The StoreData for this table (if managed).

getDatastoreContainerObject

public DatastoreContainerObject getDatastoreContainerObject(AbstractMemberMetaData fmd)
Returns the datastore container (table) for the specified field. Returns 'null' if the field is not (yet) known to the store manager.

Parameters:
fmd - The metadata for the field.
Returns:
The corresponding datastore container, or 'null'.

addDatastoreContainer

public void addDatastoreContainer(DatastoreContainerObject table)
Method to add a datastore container to the managed datastore classes

Parameters:
table - The datastore container

createDatastoreColumnsForReferenceField

public abstract void createDatastoreColumnsForReferenceField(JavaTypeMapping m,
                                                             DatastoreContainerObject table,
                                                             AbstractMemberMetaData fmd,
                                                             ClassLoaderResolver clr,
                                                             boolean embedded)
Method to create the necessary datastore columns for a reference field.

Parameters:
m - (Java) Mapping for the field
table - The datastore container where the datastore columns will be created
fmd - MetaData for the field/property
clr - ClassLoader resolver
embedded - Whether the field is embedded

createDatastoreColumnsForFieldUsingSubclassTable

public abstract void createDatastoreColumnsForFieldUsingSubclassTable(JavaTypeMapping m,
                                                                      DatastoreContainerObject table,
                                                                      AbstractMemberMetaData fmd,
                                                                      ClassLoaderResolver clr)
Method to create the necessary datastore columns for a field using subclass-table inheritance.

Parameters:
m - (Java) Mapping for the field
table - The datastore container where the datastore columns will be created
fmd - MetaData for the field/property
clr - ClassLoader resolver

getFieldManagerForResultProcessing

public abstract FieldManager getFieldManagerForResultProcessing(StateManager sm,
                                                                java.lang.Object rs,
                                                                StatementExpressionIndex[] stmtExprIndx)
Accessor for a FieldManager capable of processing the results of a query.

Parameters:
sm - StateManager for the object
rs - The results
stmtExprIndx - Statement expression indices for results -> fields mapping
Returns:
The FieldManager

getDatastoreClass

public DatastoreClass getDatastoreClass(java.lang.String className,
                                        ClassLoaderResolver clr)
Returns the primary datastore container serving as backing for the given class. If the class is not yet known to the store manager, AbstractStoreManager.addClass(java.lang.String, org.jpox.ClassLoaderResolver)is called to add it. Classes which have inheritance strategy of "new-table" and "superclass-table" will return a table here, whereas "subclass-table" will return null since it doesn't have a table as such.

Parameters:
className - Name of the class whose table is be returned.
clr - The ClassLoaderResolver
Returns:
The corresponding class table.
Throws:
NoTableManagedException - If the given class has no table managed in the database.

getDatastoreClass

public DatastoreClass getDatastoreClass(DatastoreIdentifier name)
Returns the JDO table having the given SQL identifier. Returns 'null' if no such table is (yet) known to the store manager.

Parameters:
name - The identifier name of the table.
Returns:
The corresponding JDO table, or 'null'

getClassWithPrimaryKeyForClass

public AbstractClassMetaData getClassWithPrimaryKeyForClass(AbstractClassMetaData cmd,
                                                            ClassLoaderResolver clr)
Utility to navigate the inheritance hierarchy to find the base class that defines the primary keys for this tree. This will either go up to the next class in the hierarchy that has a table OR go up to the base class, whichever is first.

Parameters:
cmd - AbstractClassMetaData for this class
clr - The ClassLoaderResolver
Returns:
The AbstractClassMetaData for the class defining the primary keys

getClassesManagingTableForClass

public AbstractClassMetaData[] getClassesManagingTableForClass(AbstractClassMetaData cmd,
                                                               ClassLoaderResolver clr)
Method to return the class(es) that has a table managing the persistence of the fields of the supplied class. For the 3 inheritance strategies, the following occurs :-

Parameters:
cmd - The supplied class.
clr - ClassLoader resolver
Returns:
The ClassMetaData's managing the fields of the supplied class


Copyright © -2008 . All Rights Reserved.