org.datanucleus.store.rdbms.table
Class SecondaryTable

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
              extended by org.datanucleus.store.rdbms.table.SecondaryTable
All Implemented Interfaces:
org.datanucleus.store.mapped.DatastoreClass, org.datanucleus.store.mapped.DatastoreContainerObject, org.datanucleus.store.mapped.SecondaryDatastoreClass, Table

public class SecondaryTable
extends AbstractClassTable
implements org.datanucleus.store.mapped.SecondaryDatastoreClass

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.


Field Summary
 
Fields inherited from class org.datanucleus.store.rdbms.table.AbstractClassTable
datastoreIDMapping, discriminatorMapping, discriminatorMetaData, highestMemberNumber, idMapping, memberMappingsMap, pkMappings, versionMapping, versionMetaData
 
Fields inherited from class org.datanucleus.store.rdbms.table.AbstractTable
columns, columnsByName, dba, existsInDatastore, identifier, LOCALISER, state, storeMgr
 
Method Summary
 org.datanucleus.store.mapped.DatastoreClass getBaseDatastoreClassWithMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)
          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.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData fmd, int mappingType)
           
 org.datanucleus.metadata.IdentityType getIdentityType()
          Accessor for the identity-type.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getIDMapping()
          Accessor for the ID mapping for this table.
 org.datanucleus.metadata.JoinMetaData getJoinMetaData()
          Accessor for the JoinMetaData which is used to join to the primary DatastoreClass.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
          Accessor for the field/property Mapping.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(java.lang.String fieldName)
          Accessor for the field mapping for the specified field.
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMappingInDatastoreClass(org.datanucleus.metadata.AbstractMemberMetaData mmd)
          Accessor for the mapping for the specified field only in this datastore class.
 org.datanucleus.metadata.AbstractMemberMetaData getMetaDataForExternalMapping(org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping, int mappingType)
           
 org.datanucleus.store.mapped.DatastoreClass getPrimaryDatastoreClass()
          Accessor for the primary datastore class that this is dependent on.
 PrimaryKey getPrimaryKey()
          Accessor for the primary key for this table.
 java.util.Collection getSecondaryDatastoreClasses()
          Accessor for any secondary tables for this table.
 org.datanucleus.store.mapped.DatastoreClass getSuperDatastoreClass()
          Accessor for the supertable for this table.
 java.lang.String getType()
          Accessor for the main type represented here.
 void initialize(org.datanucleus.ClassLoaderResolver clr)
          Method to initialise the table.
protected  void initializePK(org.datanucleus.ClassLoaderResolver clr)
          Method to initialise the primary key of this table.
 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
 boolean isSuperDatastoreClass(org.datanucleus.store.mapped.DatastoreClass table)
          Accessor whether the supplied DatastoreClass is a supertable of this table.
 boolean managesClass(java.lang.String className)
          Accessor for whether this table manages the specified class
 void postInitialize(org.datanucleus.ClassLoaderResolver clr)
          Post initilize.
 void preInitialize(org.datanucleus.ClassLoaderResolver clr)
          Pre initilize.
 void provideExternalMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer, int mappingType)
           
 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 provideUnmappedDatastoreFields(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
          Method to provide all unmapped datastore fields (columns) to the consumer.
 
Methods inherited from class org.datanucleus.store.rdbms.table.AbstractClassTable
addMemberMapping, getDataStoreObjectIdMapping, getDiscriminatorMapping, getMappingForMemberName, getPrimaryDatastoreContainerObject, getVersionMapping, managesMapping, managesMember, provideDatastoreIdMappings, provideDiscriminatorMappings, provideMappingsForMembers, provideNonPrimaryKeyMappings, provideVersionMappings
 
Methods inherited from class org.datanucleus.store.rdbms.table.TableImpl
createConstraints, dropConstraints, getExpectedCandidateKeys, getExpectedForeignKeys, getExpectedIndices, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, getSQLCreateStatements, getSQLDropStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, 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.mapped.DatastoreClass
getDataStoreObjectIdMapping, managesMapping, provideDatastoreIdMappings, provideDiscriminatorMappings, provideMappingsForMembers, provideNonPrimaryKeyMappings, provideVersionMappings, toString
 
Methods inherited from interface org.datanucleus.store.mapped.DatastoreContainerObject
addDatastoreField, getDatastoreField, getDatastoreFields, getDiscriminatorMapping, getDiscriminatorMetaData, getIdentifier, getStoreManager, getVersionMapping, getVersionMetaData, hasDatastoreField
 

Method Detail

preInitialize

public void preInitialize(org.datanucleus.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(org.datanucleus.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(org.datanucleus.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(org.datanucleus.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.

getPrimaryDatastoreClass

public org.datanucleus.store.mapped.DatastoreClass getPrimaryDatastoreClass()
Accessor for the primary datastore class that this is dependent on.

Specified by:
getPrimaryDatastoreClass in interface org.datanucleus.store.mapped.SecondaryDatastoreClass
Returns:
The associated primary datastore class.

getJoinMetaData

public org.datanucleus.metadata.JoinMetaData getJoinMetaData()
Accessor for the JoinMetaData which is used to join to the primary DatastoreClass.

Specified by:
getJoinMetaData in interface org.datanucleus.store.mapped.SecondaryDatastoreClass
Returns:
JoinMetaData

getIdentityType

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

Specified by:
getIdentityType in interface org.datanucleus.store.mapped.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 org.datanucleus.store.mapped.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 org.datanucleus.store.mapped.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 org.datanucleus.store.mapped.DatastoreClass
Returns:
true if this table is a root table

getBaseDatastoreClassWithMember

public org.datanucleus.store.mapped.DatastoreClass getBaseDatastoreClassWithMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Convenience accessor for the base table for this table which has the specified field.

Specified by:
getBaseDatastoreClassWithMember in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
mmd - Field MetaData for this field
Returns:
The base table which has the field specified

getSuperDatastoreClass

public org.datanucleus.store.mapped.DatastoreClass getSuperDatastoreClass()
Accessor for the supertable for this table.

Specified by:
getSuperDatastoreClass in interface org.datanucleus.store.mapped.DatastoreClass
Returns:
The supertable

isSuperDatastoreClass

public boolean isSuperDatastoreClass(org.datanucleus.store.mapped.DatastoreClass table)
Accessor whether the supplied DatastoreClass is a supertable of this table.

Specified by:
isSuperDatastoreClass in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
table - The DatastoreClass to check
Returns:
Whether it is a supertable (somewhere up the inheritance tree)

getSecondaryDatastoreClasses

public java.util.Collection getSecondaryDatastoreClasses()
Accessor for any secondary tables for this table.

Specified by:
getSecondaryDatastoreClasses in interface org.datanucleus.store.mapped.DatastoreClass
Returns:
Secondary tables (if any)

managesClass

public boolean managesClass(java.lang.String className)
Accessor for whether this table manages the specified class

Specified by:
managesClass in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
className - Name of the class
Returns:
Whether it is managed by this table

getExpectedForeignKeys

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

Returns:
The expected foreign keys.

getMemberMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor for the field/property Mapping. Returns the mapping if it is present in this table.

Specified by:
getMemberMapping in interface org.datanucleus.store.mapped.DatastoreClass
Specified by:
getMemberMapping in interface org.datanucleus.store.mapped.DatastoreContainerObject
Parameters:
mmd - Field MetaData for this field/property
Returns:
the Mapping for the field/property

getMemberMappingInDatastoreClass

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMappingInDatastoreClass(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor for the mapping for the specified field only in this datastore class.

Specified by:
getMemberMappingInDatastoreClass in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
mmd - Metadata of the field/property
Returns:
The Mapping for the field (or null if not present here)

getMemberMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getMemberMapping(java.lang.String fieldName)
Accessor for the field mapping for the specified field. TODO Use of this is discouraged since the fieldName is not fully qualified and if a superclass-table inheritance is used we could have 2 fields of that name here.

Specified by:
getMemberMapping in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
fieldName - Name of the field
Returns:
The mapping for the field

getIDMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getIDMapping()
Accessor for the ID mapping for this table.

Specified by:
getIDMapping in interface org.datanucleus.store.mapped.DatastoreContainerObject
Returns:
The ID mapping

providePrimaryKeyMappings

public 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).

Specified by:
providePrimaryKeyMappings in interface org.datanucleus.store.mapped.DatastoreClass
Specified by:
providePrimaryKeyMappings in class AbstractClassTable
Parameters:
consumer - Consumer for the mappings

provideExternalMappings

public void provideExternalMappings(org.datanucleus.store.mapped.mapping.MappingConsumer consumer,
                                    int mappingType)
Specified by:
provideExternalMappings in interface org.datanucleus.store.mapped.DatastoreClass

provideUnmappedDatastoreFields

public void provideUnmappedDatastoreFields(org.datanucleus.store.mapped.mapping.MappingConsumer consumer)
Method to provide all unmapped datastore fields (columns) to the consumer.

Specified by:
provideUnmappedDatastoreFields in interface org.datanucleus.store.mapped.DatastoreClass
Parameters:
consumer - Consumer of information

getExternalMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData fmd,
                                                                               int mappingType)
Specified by:
getExternalMapping in interface org.datanucleus.store.mapped.DatastoreClass

getMetaDataForExternalMapping

public org.datanucleus.metadata.AbstractMemberMetaData getMetaDataForExternalMapping(org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping,
                                                                                     int mappingType)
Specified by:
getMetaDataForExternalMapping in interface org.datanucleus.store.mapped.DatastoreClass


Copyright © 2009. All Rights Reserved.