org.jpox.store.rdbms.table
Class SecondaryTable

java.lang.Object
  extended byorg.jpox.store.rdbms.table.AbstractTable
      extended byorg.jpox.store.rdbms.table.TableImpl
          extended byorg.jpox.store.rdbms.table.AbstractClassTable
              extended byorg.jpox.store.rdbms.table.SecondaryTable
All Implemented Interfaces:
DatastoreClass, DatastoreContainerObject, DatastoreObject, Table

public class SecondaryTable
extends AbstractClassTable
implements DatastoreClass

Representation of a secondary table for a class. Has a primary table that manages the main fields for that class and some fields are defined (using ) to be stored in the secondary table. Many of the methods in this class defer to the equivalent method in the primary table.

Version:
$Revision: 1.29 $

Field Summary
 
Fields inherited from class org.jpox.store.rdbms.table.AbstractClassTable
datastoreIDMapping, discriminatorMapping, fieldMappingsMap, highestFieldNumber, idMapping, pkMappings, versionMapping
 
Fields inherited from class org.jpox.store.rdbms.table.AbstractTable
columns, columnsByName, dba, ddlDumpWriter, identifier, LOCALISER, state, storeMgr
 
Fields inherited from interface org.jpox.store.rdbms.table.Table
TABLE_STATE_INITIALIZED, TABLE_STATE_INITIALIZED_MODIFIED, TABLE_STATE_NEW, TABLE_STATE_PK_INITIALIZED, TABLE_STATE_VALIDATED, TABLE_TYPE_MISSING, TABLE_TYPE_TABLE, TABLE_TYPE_UNKNOWN, TABLE_TYPE_VIEW
 
Method Summary
 void delete(StateManager sm)
          Method to delete an object for this class.
 void deleteDependent(StateManager sm, AbstractPropertyMetaData[] fields)
          Method to delete all dependent objects.
 void fetch(StateManager sm, AbstractPropertyMetaData[] fieldMetaData)
          Method to fetch an object for this class.
 DatastoreClass getBaseDatastoreClassWithField(AbstractPropertyMetaData fmd)
          Convenience accessor for the base table for this table which has the specified field.
protected  java.util.List getExpectedForeignKeys()
          Accessor for the expected foreign keys for this table.
 JavaTypeMapping getExternalFkDiscriminatorMapping(AbstractPropertyMetaData fmd)
          Accessor for the external FK discriminator mapping for an owner field.
 JavaTypeMapping getExternalFkMapping(AbstractPropertyMetaData fmd)
          Accessor for the external FK mapping for an owner field.
 JavaTypeMapping getExternalOrderMapping(AbstractPropertyMetaData fmd)
          Accessor for the external order mapping specified by the field.
 JavaTypeMapping getFieldMapping(AbstractPropertyMetaData fmd)
          Accessor for the field Mapping.
 JavaTypeMapping getFieldMapping(java.lang.String fieldName)
          Accessor for the field mapping for the specified field.
 AbstractPropertyMetaData getFieldMetaData(java.lang.String fieldName)
          Accessor for the field metadata for the specified field name.
 IdentityType getIdentityType()
          Accessor for the identity-type.
 JavaTypeMapping getIDMapping()
          Accessor for the ID mapping for this table.
 DatastoreContainerObject getPrimaryDatastoreContainerObject()
          Accessor for the primary table associated with this table
 PrimaryKey getPrimaryKey()
          Accessor for the primary key for this table.
 java.lang.String getType()
          Accessor for the main type represented here.
 void initialize(ClassLoaderResolver clr)
          Method to initialise the table.
protected  void initializePK(ClassLoaderResolver clr)
          Method to initialise the primary key of this table.
 void insert(StateManager sm)
          Method to insert an object for this class.
 boolean isBaseDatastoreClass()
          Whether this table is the base in the inheritance hierarchy.
 boolean isObjectIDDatastoreAttributed()
          Whether this table or super table has id (primary key) attributed by the datastore
 void locate(StateManager sm)
          Locates this object in the datastore.
 java.lang.Object newOID(PersistenceManager sm, javax.jdo.spi.PersistenceCapable pcClass)
          Create a new OID.
 void postInitialize(ClassLoaderResolver clr)
          Post initilize.
 void preInitialize(ClassLoaderResolver clr)
          Pre initilize.
 void provideExternalFkMappings(MappingConsumer consumer)
          Provide the mappings to external FK mappings
 void provideExternalOrderMappings(MappingConsumer consumer)
          Provide the mappings to external order mappings
 void providePrimaryKeyMappings(MappingConsumer consumer)
          Provide the mappings to the consumer for all primary-key fields mapped to this table (for application identity).
 void update(StateManager sm, AbstractPropertyMetaData[] fieldMetaData)
          Method to update an object for this class.
 
Methods inherited from class org.jpox.store.rdbms.table.AbstractClassTable
addFieldMapping, getDataStoreObjectIdMapping, getDefaultNameForType, getDiscriminatorMapping, getVersionMapping, managesField, provideDatastoreIdMappings, provideDiscriminatorMappings, provideMappingsForFields, provideNonPrimaryKeyMappings, provideVersionMappings
 
Methods inherited from class org.jpox.store.rdbms.table.TableImpl
dropConstraints, getExpectedCandidateKeys, getExpectedForeignKeys, getExpectedIndices, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, getSQLCreateStatements, getSQLDropStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, validate, validateColumns, validateConstraints, validatePrimaryKey
 
Methods inherited from class org.jpox.store.rdbms.table.AbstractTable
addColumnInternal, addDatastoreField, allowDdlDump, assertIsInitialized, assertIsInitializedModified, assertIsPKInitialized, assertIsPKUninitialized, assertIsUninitialized, assertIsValidated, create, drop, equals, executeDdlStatement, executeDdlStatementList, exists, getCatalogName, getDatastoreIdentifierFullyQualified, getDiscriminatorMetaData, getIdentifier, getSchemaName, getStoreManager, getVersionMetaData, hasColumnName, hasDatastoreField, hashCode, isDumpingDdl, isInitialized, isInitializedModified, isPKInitialized, isValidated, setDdlDumpWriter, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jpox.store.DatastoreClass
getDataStoreObjectIdMapping, provideDatastoreIdMappings, provideDiscriminatorMappings, provideMappingsForFields, provideNonPrimaryKeyMappings, provideVersionMappings, toString
 
Methods inherited from interface org.jpox.store.DatastoreContainerObject
addDatastoreField, getDiscriminatorMapping, getDiscriminatorMetaData, getVersionMapping, getVersionMetaData, hasDatastoreField
 
Methods inherited from interface org.jpox.store.DatastoreObject
getIdentifier, getStoreManager
 

Method Detail

preInitialize

public void preInitialize(ClassLoaderResolver clr)
Pre initilize. For things that must be initialized right after constructor

Specified by:
preInitialize in interface Table
Overrides:
preInitialize in class TableImpl
Parameters:
clr - the ClassLoaderResolver

postInitialize

public void postInitialize(ClassLoaderResolver clr)
Post initilize. For things that must be set after all classes have been initialized before

Specified by:
postInitialize in interface Table
Overrides:
postInitialize in class TableImpl
Parameters:
clr - the ClassLoaderResolver

initialize

public void initialize(ClassLoaderResolver clr)
Method to initialise the table. This will initialise the primary key columns for the table. Any other columns are added via the addFieldMapping() method.

Specified by:
initialize in interface Table
Parameters:
clr - The ClassLoaderResolver

initializePK

protected void initializePK(ClassLoaderResolver clr)
Method to initialise the primary key of this table.

Specified by:
initializePK in class AbstractClassTable
Parameters:
clr - The ClassLoaderResolver
See Also:
AbstractClassTable.initializePK(ClassLoaderResolver)

getPrimaryKey

public PrimaryKey getPrimaryKey()
Accessor for the primary key for this table. Overrides the method in TableImpl to add on any specification of PK name in the metadata.

Overrides:
getPrimaryKey in class TableImpl
Returns:
The primary key.

getPrimaryDatastoreContainerObject

public DatastoreContainerObject getPrimaryDatastoreContainerObject()
Accessor for the primary table associated with this table

Overrides:
getPrimaryDatastoreContainerObject in class AbstractClassTable
Returns:
The associated primary table

getIdentityType

public IdentityType getIdentityType()
Accessor for the identity-type. Simply returns the same as the primary table

Specified by:
getIdentityType in interface DatastoreClass
Specified by:
getIdentityType in class AbstractClassTable
Returns:
identity-type tag value

getType

public java.lang.String getType()
Accessor for the main type represented here.

Specified by:
getType in interface DatastoreClass
Returns:
Name of the principal class represented

isObjectIDDatastoreAttributed

public boolean isObjectIDDatastoreAttributed()
Whether this table or super table has id (primary key) attributed by the datastore

Specified by:
isObjectIDDatastoreAttributed in interface DatastoreClass
Specified by:
isObjectIDDatastoreAttributed in class AbstractClassTable
Returns:
true if the id attributed by the datastore

isBaseDatastoreClass

public boolean isBaseDatastoreClass()
Whether this table is the base in the inheritance hierarchy.

Specified by:
isBaseDatastoreClass in interface DatastoreClass
Returns:
true if this table is a root table

getBaseDatastoreClassWithField

public DatastoreClass getBaseDatastoreClassWithField(AbstractPropertyMetaData fmd)
Convenience accessor for the base table for this table which has the specified field.

Specified by:
getBaseDatastoreClassWithField in interface DatastoreClass
Parameters:
fmd - Field MetaData for this field
Returns:
The base table which has the field specified

insert

public void insert(StateManager sm)
Method to insert an object for this class. Will insert any superclass records as well (recursive).

Specified by:
insert in interface DatastoreClass
Parameters:
sm - StateManager for the object to insert.

fetch

public void fetch(StateManager sm,
                  AbstractPropertyMetaData[] fieldMetaData)
Method to fetch an object for this class. Will fetch any superclass records as well (recursive).

Specified by:
fetch in interface DatastoreClass
Parameters:
sm - StateManager for the object to fetch.
fieldMetaData - MetaData for the fields to be fetched

update

public void update(StateManager sm,
                   AbstractPropertyMetaData[] fieldMetaData)
Method to update an object for this class. Will update any superclass records as well (recursive).

Specified by:
update in interface DatastoreClass
Parameters:
sm - StateManager for the object to update.
fieldMetaData - MetaData for the fields to be updated

delete

public void delete(StateManager sm)
Method to delete an object for this class. Will delete any superclass records as well (recursive).

Specified by:
delete in interface DatastoreClass
Parameters:
sm - StateManager for the object to delete.

locate

public void locate(StateManager sm)
Locates this object in the datastore.

Specified by:
locate in interface DatastoreClass
Parameters:
sm - The StateManager for the object to be found
Throws:
javax.jdo.JDOObjectNotFoundException - If the instance does not exist in the datastore

deleteDependent

public void deleteDependent(StateManager sm,
                            AbstractPropertyMetaData[] fields)
Method to delete all dependent objects. Not used here since a secondary table has no such dependents

Specified by:
deleteDependent in interface DatastoreClass
Parameters:
sm - The State Manager
fields - MetaData for the fields

getExpectedForeignKeys

protected java.util.List getExpectedForeignKeys()
Accessor for the expected foreign keys for this table.

Returns:
The expected foreign keys.

getFieldMapping

public JavaTypeMapping getFieldMapping(AbstractPropertyMetaData fmd)
Accessor for the field Mapping. Returns the mapping if it is present in this table.

Specified by:
getFieldMapping in interface DatastoreClass
Parameters:
fmd - Field MetaData for this field
Returns:
the Mapping for the field

getFieldMapping

public JavaTypeMapping getFieldMapping(java.lang.String fieldName)
Accessor for the field mapping for the specified field.

Specified by:
getFieldMapping in interface DatastoreClass
Parameters:
fieldName - Name of the field
Returns:
The mapping for the field

getFieldMetaData

public AbstractPropertyMetaData getFieldMetaData(java.lang.String fieldName)
Accessor for the field metadata for the specified field name.

Specified by:
getFieldMetaData in interface DatastoreClass
Parameters:
fieldName - Name of the field
Returns:
FieldMetaData for the field

getIDMapping

public JavaTypeMapping getIDMapping()
Accessor for the ID mapping for this table.

Specified by:
getIDMapping in interface DatastoreContainerObject
Returns:
The ID mapping

providePrimaryKeyMappings

public void providePrimaryKeyMappings(MappingConsumer consumer)
Provide the mappings to the consumer for all primary-key fields mapped to this table (for application identity).

Specified by:
providePrimaryKeyMappings in interface DatastoreClass
Specified by:
providePrimaryKeyMappings in class AbstractClassTable
Parameters:
consumer - Consumer for the mappings

provideExternalFkMappings

public void provideExternalFkMappings(MappingConsumer consumer)
Description copied from interface: DatastoreClass
Provide the mappings to external FK mappings

Specified by:
provideExternalFkMappings in interface DatastoreClass
Parameters:
consumer - Consumer for the mappings

provideExternalOrderMappings

public void provideExternalOrderMappings(MappingConsumer consumer)
Description copied from interface: DatastoreClass
Provide the mappings to external order mappings

Specified by:
provideExternalOrderMappings in interface DatastoreClass
Parameters:
consumer - Consumer for the mappings

newOID

public java.lang.Object newOID(PersistenceManager sm,
                               javax.jdo.spi.PersistenceCapable pcClass)
Description copied from interface: DatastoreClass
Create a new OID. OID can be datastore identity or application identity

Specified by:
newOID in interface DatastoreClass
Parameters:
sm - The PersistenceManager
pcClass - The Persistence-Capable class
Returns:
New OID

getExternalOrderMapping

public JavaTypeMapping getExternalOrderMapping(AbstractPropertyMetaData fmd)
Description copied from interface: DatastoreClass
Accessor for the external order mapping specified by the field.

Specified by:
getExternalOrderMapping in interface DatastoreClass
Parameters:
fmd - The metadata for the List field.
Returns:
The index mapping for the specified field.

getExternalFkDiscriminatorMapping

public JavaTypeMapping getExternalFkDiscriminatorMapping(AbstractPropertyMetaData fmd)
Description copied from interface: DatastoreClass
Accessor for the external FK discriminator mapping for an owner field.

Specified by:
getExternalFkDiscriminatorMapping in interface DatastoreClass
Parameters:
fmd - The metadata for the field.
Returns:
The external mapping for the specified field.

getExternalFkMapping

public JavaTypeMapping getExternalFkMapping(AbstractPropertyMetaData fmd)
Description copied from interface: DatastoreClass
Accessor for the external FK mapping for an owner field.

Specified by:
getExternalFkMapping in interface DatastoreClass
Parameters:
fmd - The metadata for the field.
Returns:
The external mapping for the specified field.


Copyright © -2007 . All Rights Reserved.