org.jpox.store.rdbms.table
Class AbstractClassTable

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

public abstract class AbstractClassTable
extends TableImpl

Abstract representation of a table for a class. Abstracts out the common parts of a primary ClassTable and a SecondaryClassTable.

Mappings

A Table is built from a series of field mappings. Each Java class has a series of fields and each of these has an associated JavaTypeMapping. Each JavaTypeMapping has related DatastoreMapping(s). These are used in mapping the Java class to the table, and are used when populating the table, and when retrieving data from the table back to the object. There are several categories of mappings in this class

Version:
$Revision: 1.31 $

Field Summary
protected  JavaTypeMapping datastoreIDMapping
          Mapping for datastore identity (optional).
protected  JavaTypeMapping discriminatorMapping
          Mapping for any discriminator column.
protected  java.util.Map fieldMappingsMap
          Mappings for fields mapped to this table, keyed by the FieldMetaData.
protected  int highestFieldNumber
          Highest absolute field number managed by this table
protected  JavaTypeMapping idMapping
          Mapping for the id of the table.
protected  JavaTypeMapping[] pkMappings
          Mappings for application identity (optional).
protected  JavaTypeMapping versionMapping
          Mapping for any version/timestamp column.
 
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
 
Constructor Summary
AbstractClassTable(DatastoreIdentifier tableName, RDBMSManager storeMgr)
          Constructor.
 
Method Summary
protected  void addFieldMapping(JavaTypeMapping fieldMapping)
          Utility to add the mapping for a field to the managed list.
 JavaTypeMapping getDataStoreObjectIdMapping()
          Accessor for a mapping for the datastore ID (OID) for this table.
protected  DatastoreIdentifier getDefaultNameForType(java.lang.String className, ClassLoaderResolver clr)
          Accessor for the column name for the specified class.
 JavaTypeMapping getDiscriminatorMapping()
          Accessor for the discriminator mapping specified .
abstract  IdentityType getIdentityType()
          Accessor for the identity-type.
 DatastoreContainerObject getPrimaryDatastoreContainerObject()
          Convenience method to return the primary table.
 JavaTypeMapping getVersionMapping()
          Accessor for the version mapping specified .
protected abstract  void initializePK(ClassLoaderResolver clr)
          Method to initialise the table primary key field(s).
abstract  boolean isObjectIDDatastoreAttributed()
          Accessor for whether the table has its identity attributed by the datastore (e.g using autoincrement)
 boolean managesField(java.lang.String fieldName)
          Convenience method for whether the (fully-specified) field is managed by this table
 void provideDatastoreIdMappings(MappingConsumer consumer)
          Accessor for a mapping for the datastore ID (OID) for this table.
 void provideDiscriminatorMappings(MappingConsumer consumer)
          Provide the mappings to discriminator mappings
 void provideMappingsForFields(MappingConsumer consumer, AbstractPropertyMetaData[] fieldMetaData, boolean includeSecondaryTables)
          Provide the mappings to the consumer for all absolute field Numbers in this table that are container in the fieldNumbers parameter.
 void provideNonPrimaryKeyMappings(MappingConsumer consumer)
          Provide the mappings to the consumer for all non primary-key fields mapped to this table.
abstract  void providePrimaryKeyMappings(MappingConsumer consumer)
          Provide the mappings to the consumer for all primary-key fields mapped to this table (for application identity).
 void provideVersionMappings(MappingConsumer consumer)
          Provide the mappings to version mappings
 
Methods inherited from class org.jpox.store.rdbms.table.TableImpl
dropConstraints, getExpectedCandidateKeys, getExpectedForeignKeys, getExpectedIndices, getPrimaryKey, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, getSQLCreateStatements, getSQLDropStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, postInitialize, preInitialize, 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.rdbms.table.Table
initialize
 
Methods inherited from interface org.jpox.store.DatastoreContainerObject
getFieldMapping, getIDMapping
 

Field Detail

fieldMappingsMap

protected java.util.Map fieldMappingsMap
Mappings for fields mapped to this table, keyed by the FieldMetaData.


datastoreIDMapping

protected JavaTypeMapping datastoreIDMapping
Mapping for datastore identity (optional).


pkMappings

protected JavaTypeMapping[] pkMappings
Mappings for application identity (optional).


idMapping

protected JavaTypeMapping idMapping
Mapping for the id of the table.


versionMapping

protected JavaTypeMapping versionMapping
Mapping for any version/timestamp column.


discriminatorMapping

protected JavaTypeMapping discriminatorMapping
Mapping for any discriminator column.


highestFieldNumber

protected int highestFieldNumber
Highest absolute field number managed by this table

Constructor Detail

AbstractClassTable

public AbstractClassTable(DatastoreIdentifier tableName,
                          RDBMSManager storeMgr)
Constructor.

Parameters:
tableName - Name of the table
storeMgr - Store Manager that is managing this instance
Method Detail

getPrimaryDatastoreContainerObject

public DatastoreContainerObject getPrimaryDatastoreContainerObject()
Convenience method to return the primary table.

Returns:
The primary table for this table

initializePK

protected abstract void initializePK(ClassLoaderResolver clr)
Method to initialise the table primary key field(s).

Parameters:
clr - The ClassLoaderResolver

managesField

public boolean managesField(java.lang.String fieldName)
Convenience method for whether the (fully-specified) field is managed by this table

Parameters:
fieldName - Fully qualified name of the field
Returns:
Whether it is managed

addFieldMapping

protected void addFieldMapping(JavaTypeMapping fieldMapping)
Utility to add the mapping for a field to the managed list.

Parameters:
fieldMapping - The mapping for the field

getIdentityType

public abstract IdentityType getIdentityType()
Accessor for the identity-type.

Returns:
identity-type tag value

isObjectIDDatastoreAttributed

public abstract boolean isObjectIDDatastoreAttributed()
Accessor for whether the table has its identity attributed by the datastore (e.g using autoincrement)

Returns:
Whether it is datastore attributed

getDefaultNameForType

protected DatastoreIdentifier getDefaultNameForType(java.lang.String className,
                                                    ClassLoaderResolver clr)
Accessor for the column name for the specified class.

Parameters:
className - Name of the class for which the column is required.
clr - The ClassLoaderResolver
Returns:
The SQL identifier of the column.

getDataStoreObjectIdMapping

public JavaTypeMapping getDataStoreObjectIdMapping()
Accessor for a mapping for the datastore ID (OID) for this table.

Returns:
The (OID) mapping.

getVersionMapping

public JavaTypeMapping getVersionMapping()
Accessor for the version mapping specified .

Specified by:
getVersionMapping in interface DatastoreContainerObject
Overrides:
getVersionMapping in class AbstractTable
Returns:
The version mapping.

getDiscriminatorMapping

public JavaTypeMapping getDiscriminatorMapping()
Accessor for the discriminator mapping specified .

Specified by:
getDiscriminatorMapping in interface DatastoreContainerObject
Overrides:
getDiscriminatorMapping in class AbstractTable
Returns:
The mapping for the discriminator column

provideDatastoreIdMappings

public final void provideDatastoreIdMappings(MappingConsumer consumer)
Accessor for a mapping for the datastore ID (OID) for this table.

Parameters:
consumer - Consumer for the mappings

providePrimaryKeyMappings

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

Parameters:
consumer - Consumer for the mappings

provideNonPrimaryKeyMappings

public final void provideNonPrimaryKeyMappings(MappingConsumer consumer)
Provide the mappings to the consumer for all non primary-key fields mapped to this table.

Parameters:
consumer - Consumer for the mappings

provideMappingsForFields

public void provideMappingsForFields(MappingConsumer consumer,
                                     AbstractPropertyMetaData[] fieldMetaData,
                                     boolean includeSecondaryTables)
Provide the mappings to the consumer for all absolute field Numbers in this table that are container in the fieldNumbers parameter.

Parameters:
consumer - Consumer for the mappings
fieldMetaData - MetaData for the fields to provide mappings for
includeSecondaryTables - Whether to provide fields in secondary tables

provideVersionMappings

public final void provideVersionMappings(MappingConsumer consumer)
Provide the mappings to version mappings

Parameters:
consumer - Consumer for the version mappings

provideDiscriminatorMappings

public final void provideDiscriminatorMappings(MappingConsumer consumer)
Provide the mappings to discriminator mappings

Parameters:
consumer - Consumer for the mappings


Copyright © -2007 . All Rights Reserved.