org.datanucleus.store.rdbms.table
Class AbstractClassTable

java.lang.Object
  extended by org.datanucleus.store.rdbms.table.AbstractTable
      extended by org.datanucleus.store.rdbms.table.TableImpl
          extended by org.datanucleus.store.rdbms.table.AbstractClassTable
All Implemented Interfaces:
org.datanucleus.store.mapped.DatastoreContainerObject, 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


Field Summary
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping datastoreIDMapping
          Mapping for datastore identity (optional).
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping discriminatorMapping
          Mapping for any discriminator column.
protected  org.datanucleus.metadata.DiscriminatorMetaData discriminatorMetaData
          MetaData for discriminator for objects stored in this table.
protected  int highestMemberNumber
          Highest absolute field/property number managed by this table
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping idMapping
          Mapping for the id of the table.
protected  java.util.Map<org.datanucleus.metadata.AbstractMemberMetaData,org.datanucleus.store.mapped.mapping.JavaTypeMapping> memberMappingsMap
          Mappings for members mapped to this table, keyed by the metadata for the member.
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping[] pkMappings
          Mappings for application identity (optional).
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping versionMapping
          Mapping for any version/timestamp column.
protected  org.datanucleus.metadata.VersionMetaData versionMetaData
          MetaData for versioning of objects stored in this table.
 
Fields inherited from class org.datanucleus.store.rdbms.table.AbstractTable
columns, columnsByName, dba, existsInDatastore, identifier, LOCALISER, state, storeMgr
 
Constructor Summary
AbstractClassTable(org.datanucleus.store.mapped.DatastoreIdentifier tableName, RDBMSManager storeMgr)
          Constructor.
 
Method Summary
protected  void addMemberMapping(org.datanucleus.store.mapped.mapping.JavaTypeMapping fieldMapping)
          Utility to add the mapping for a field/property to the managed list.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getDataStoreObjectIdMapping()
          Accessor for a mapping for the datastore ID (OID) for this table.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getDiscriminatorMapping(boolean allowSuperclasses)
          Accessor for the discriminator mapping specified .
abstract  org.datanucleus.metadata.IdentityType getIdentityType()
          Accessor for the identity-type.
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping getMappingForMemberName(java.lang.String memberName)
          Accessor for the JavaTypeMapping that is handling the member of the specified name.
 org.datanucleus.store.mapped.DatastoreContainerObject getPrimaryDatastoreContainerObject()
          Convenience method to return the primary table.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getVersionMapping(boolean allowSuperclasses)
          Accessor for the version mapping specified .
protected abstract  void initializePK(org.datanucleus.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 managesMapping(org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping)
          Convenience method to return if this table manages the columns for the supplied mapping.
 boolean managesMember(java.lang.String memberName)
          Convenience method for whether the (fully-specified) member is managed by this table
 void provideDatastoreIdMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
          Accessor for a mapping for the datastore ID (OID) for this table.
 void provideDiscriminatorMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
          Provide the discriminator mappings
 void provideMappingsForMembers(org.datanucleus.store.mapped.mapping.MappingConsumer consumer, org.datanucleus.metadata.AbstractMemberMetaData[] mmds, boolean includeSecondaryTables)
          Provide the mappings to the consumer for all specified members.
 void provideNonPrimaryKeyMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
          Provide the mappings to the consumer for all non primary-key fields mapped to this table.
abstract  void providePrimaryKeyMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
          Provide the mappings to the consumer for all primary-key fields mapped to this table (for application identity).
 void provideVersionMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
          Provide the version mappings.
 
Methods inherited from class org.datanucleus.store.rdbms.table.TableImpl
createConstraints, dropConstraints, getExpectedCandidateKeys, getExpectedForeignKeys, getExpectedIndices, getPrimaryKey, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, getSQLCreateStatements, getSQLDropStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, postInitialize, preInitialize, validate, validateColumns, validateConstraints, validatePrimaryKey
 
Methods inherited from class org.datanucleus.store.rdbms.table.AbstractTable
addColumnInternal, addDatastoreField, allowDDLOutput, assertIsInitialized, assertIsInitializedModified, assertIsPKInitialized, assertIsPKUninitialized, assertIsUninitialized, assertIsValidated, create, drop, equals, executeDdlStatement, executeDdlStatementList, exists, getCatalogName, getDatastoreField, getDatastoreFields, getDatastoreIdentifierFullyQualified, getDiscriminatorMetaData, getIdentifier, getSchemaName, getStoreManager, getVersionMetaData, hasColumnName, hasDatastoreField, hashCode, isInitialized, isInitializedModified, isPKInitialized, isValidated, tableExistsInDatastore, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.datanucleus.store.rdbms.table.Table
initialize
 
Methods inherited from interface org.datanucleus.store.mapped.DatastoreContainerObject
getIDMapping, getMemberMapping
 

Field Detail

memberMappingsMap

protected java.util.Map<org.datanucleus.metadata.AbstractMemberMetaData,org.datanucleus.store.mapped.mapping.JavaTypeMapping> memberMappingsMap
Mappings for members mapped to this table, keyed by the metadata for the member.


datastoreIDMapping

protected org.datanucleus.store.mapped.mapping.JavaTypeMapping datastoreIDMapping
Mapping for datastore identity (optional).


pkMappings

protected org.datanucleus.store.mapped.mapping.JavaTypeMapping[] pkMappings
Mappings for application identity (optional).


idMapping

protected org.datanucleus.store.mapped.mapping.JavaTypeMapping idMapping
Mapping for the id of the table.


versionMapping

protected org.datanucleus.store.mapped.mapping.JavaTypeMapping versionMapping
Mapping for any version/timestamp column.


versionMetaData

protected org.datanucleus.metadata.VersionMetaData versionMetaData
MetaData for versioning of objects stored in this table.


discriminatorMetaData

protected org.datanucleus.metadata.DiscriminatorMetaData discriminatorMetaData
MetaData for discriminator for objects stored in this table.


discriminatorMapping

protected org.datanucleus.store.mapped.mapping.JavaTypeMapping discriminatorMapping
Mapping for any discriminator column.


highestMemberNumber

protected int highestMemberNumber
Highest absolute field/property number managed by this table

Constructor Detail

AbstractClassTable

public AbstractClassTable(org.datanucleus.store.mapped.DatastoreIdentifier tableName,
                          RDBMSManager storeMgr)
Constructor.

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

getPrimaryDatastoreContainerObject

public org.datanucleus.store.mapped.DatastoreContainerObject getPrimaryDatastoreContainerObject()
Convenience method to return the primary table.

Returns:
The primary table for this table

initializePK

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

Parameters:
clr - The ClassLoaderResolver

managesMember

public boolean managesMember(java.lang.String memberName)
Convenience method for whether the (fully-specified) member is managed by this table

Parameters:
memberName - Fully qualified name of the field/property
Returns:
Whether it is managed

getMappingForMemberName

protected org.datanucleus.store.mapped.mapping.JavaTypeMapping getMappingForMemberName(java.lang.String memberName)
Accessor for the JavaTypeMapping that is handling the member of the specified name. Returns the first one that matches.

Parameters:
memberName - Name of the field/property
Returns:
The java type mapping

managesMapping

public boolean managesMapping(org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping)
Convenience method to return if this table manages the columns for the supplied mapping.

Parameters:
mapping - The mapping
Returns:
Whether the mapping is managed in this table

addMemberMapping

protected void addMemberMapping(org.datanucleus.store.mapped.mapping.JavaTypeMapping fieldMapping)
Utility to add the mapping for a field/property to the managed list.

Parameters:
fieldMapping - The mapping for the field/property

getIdentityType

public abstract org.datanucleus.metadata.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

getDataStoreObjectIdMapping

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

Returns:
The (OID) mapping.

getVersionMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getVersionMapping(boolean allowSuperclasses)
Accessor for the version mapping specified .

Specified by:
getVersionMapping in interface org.datanucleus.store.mapped.DatastoreContainerObject
Overrides:
getVersionMapping in class AbstractTable
Parameters:
allowSuperclasses - Whether we should return just the mapping from this table or whether we should return it when this table has none and the supertable has
Returns:
The version mapping.

getDiscriminatorMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getDiscriminatorMapping(boolean allowSuperclasses)
Accessor for the discriminator mapping specified .

Specified by:
getDiscriminatorMapping in interface org.datanucleus.store.mapped.DatastoreContainerObject
Overrides:
getDiscriminatorMapping in class AbstractTable
Returns:
The mapping for the discriminator column

provideDatastoreIdMappings

public final void provideDatastoreIdMappings(org.datanucleus.store.mapped.mapping.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(org.datanucleus.store.mapped.mapping.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(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
Provide the mappings to the consumer for all non primary-key fields mapped to this table.

Parameters:
consumer - Consumer for the mappings

provideMappingsForMembers

public void provideMappingsForMembers(org.datanucleus.store.mapped.mapping.MappingConsumer consumer,
                                      org.datanucleus.metadata.AbstractMemberMetaData[] mmds,
                                      boolean includeSecondaryTables)
Provide the mappings to the consumer for all specified members.

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

provideVersionMappings

public final void provideVersionMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
Provide the version mappings.

Parameters:
consumer - Consumer for the version mappings

provideDiscriminatorMappings

public final void provideDiscriminatorMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
Provide the discriminator mappings

Parameters:
consumer - Consumer for the mappings


Copyright © 2009. All Rights Reserved.