Class SecondaryTable
- java.lang.Object
-
- org.datanucleus.store.rdbms.table.AbstractTable
-
- org.datanucleus.store.rdbms.table.TableImpl
-
- org.datanucleus.store.rdbms.table.AbstractClassTable
-
- org.datanucleus.store.rdbms.table.SecondaryTable
-
- All Implemented Interfaces:
DatastoreClass,SecondaryDatastoreClass,Table,org.datanucleus.store.schema.table.Table
public class SecondaryTable extends AbstractClassTable implements 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 <field table="...">) 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
createTimestampMapping, createUserMapping, datastoreIdMapping, discriminatorMapping, discriminatorMetaData, highestMemberNumber, idMapping, memberMappingsMap, multitenancyMapping, pkMappings, softDeleteMapping, updateTimestampMapping, updateUserMapping, versionMapping, versionMetaData
-
Fields inherited from class org.datanucleus.store.rdbms.table.AbstractTable
columns, columnsByIdentifier, dba, existsInDatastore, identifier, state, storeMgr, TABLE_STATE_INITIALIZED, TABLE_STATE_INITIALIZED_MODIFIED, TABLE_STATE_NEW, TABLE_STATE_PK_INITIALIZED, TABLE_STATE_VALIDATED
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DatastoreClassgetBaseDatastoreClass()Accessor for the base datastore class.DatastoreClassgetBaseDatastoreClassWithMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)Convenience accessor for the base table for this table which has the specified member.List<ForeignKey>getExpectedForeignKeys(org.datanucleus.ClassLoaderResolver clr)Accessor for the expected foreign keys for this table.JavaTypeMappinggetExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData fmd, MappingType mappingType)Accessor for the external mapping for the specified member of the specified mapping type.org.datanucleus.metadata.IdentityTypegetIdentityType()Accessor for the identity-type.JavaTypeMappinggetIdMapping()Accessor for the ID mapping for this table.org.datanucleus.metadata.JoinMetaDatagetJoinMetaData()Accessor for the JoinMetaData which is used to join to the primary DatastoreClass.String[]getManagedClasses()Accessor for the names of all classes managed by this table.JavaTypeMappinggetMemberMapping(String memberName)Accessor for the mapping for the specified member.JavaTypeMappinggetMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)Accessor for the member Mapping.JavaTypeMappinggetMemberMappingInDatastoreClass(org.datanucleus.metadata.AbstractMemberMetaData mmd)Accessor for the mapping for the specified member only in this datastore class.org.datanucleus.metadata.AbstractMemberMetaDatagetMetaDataForExternalMapping(JavaTypeMapping mapping, MappingType mappingType)Accessor for the owner member metadata for the specified external mapping of the specified typeDatastoreClassgetPrimaryDatastoreClass()Accessor for the primary datastore class that this is dependent on.PrimaryKeygetPrimaryKey()Accessor for the primary key for this table.CollectiongetSecondaryDatastoreClasses()Accessor for any secondary tables for this table.DatastoreClassgetSuperDatastoreClass()Accessor for the supertable for this table.StringgetType()Accessor for the main type represented here.voidinitialize(org.datanucleus.ClassLoaderResolver clr)Method to initialise the table.protected voidinitializePK(org.datanucleus.ClassLoaderResolver clr)Method to initialise the primary key of this table.booleanisBaseDatastoreClass()Whether this table is the base in the inheritance hierarchy.booleanisObjectIdDatastoreAttributed()Whether this table or super table has id (primary key) attributed by the datastorebooleanisSuperDatastoreClass(DatastoreClass table)Accessor whether the supplied DatastoreClass is a supertable of this table.booleanmanagesClass(String className)Accessor for whether this table manages the specified class.voidpostInitialize(org.datanucleus.ClassLoaderResolver clr)Post initilize.voidpreInitialize(org.datanucleus.ClassLoaderResolver clr)Pre initilize.voidprovideExternalMappings(MappingConsumer consumer, MappingType mappingType)Instruction to provide all external mappings to the passed consumer.voidprovidePrimaryKeyMappings(MappingConsumer consumer)Provide the mappings to the consumer for all primary-key fields mapped to this table (for application identity).voidprovideUnmappedColumns(MappingConsumer consumer)Method to provide all unmapped columns to the consumer.-
Methods inherited from class org.datanucleus.store.rdbms.table.AbstractClassTable
addMemberMapping, getMappingForMemberName, getPrimaryTable, getSurrogateColumn, getSurrogateMapping, managesMapping, managesMember, provideMappingsForMembers, provideNonPrimaryKeyMappings, provideSurrogateMapping
-
Methods inherited from class org.datanucleus.store.rdbms.table.TableImpl
createConstraints, dropConstraints, getExpectedCandidateKeys, getExpectedIndices, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, getSQLCreateStatements, getSQLDropStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, logMapping, validate, validateColumns, validateConstraints, validatePrimaryKey
-
Methods inherited from class org.datanucleus.store.rdbms.table.AbstractTable
addColumn, addColumnInternal, allowDDLOutput, assertIsInitialized, assertIsInitializedModified, assertIsPKInitialized, assertIsPKUninitialized, assertIsUninitialized, assertIsValidated, create, drop, equals, executeDdlStatement, executeDdlStatementList, exists, getCatalogName, getClassMetaData, getColumn, getColumnForName, getColumnForPosition, getColumns, getDatastoreIdentifierFullyQualified, getDiscriminatorMetaData, getIdentifier, getMemberColumnMappingForEmbeddedMember, getMemberColumnMappingForMember, getMemberColumnMappings, getName, getNumberOfColumns, getSchemaName, getStoreManager, getVersionMetaData, hasColumn, hasColumnName, 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.DatastoreClass
managesMapping, provideMappingsForMembers, provideNonPrimaryKeyMappings, provideSurrogateMapping, toString
-
Methods inherited from interface org.datanucleus.store.rdbms.table.Table
addColumn, create, drop, exists, getColumn, getDiscriminatorMetaData, getIdentifier, getStoreManager, getSurrogateMapping, getVersionMetaData, hasColumn, isInitialized, isInitializedModified, isValidated, validate
-
Methods inherited from interface org.datanucleus.store.schema.table.Table
getCatalogName, getClassMetaData, getColumnForName, getColumnForPosition, getColumns, getMemberColumnMappingForEmbeddedMember, getMemberColumnMappingForMember, getMemberColumnMappings, getName, getNumberOfColumns, getSchemaName, getSurrogateColumn
-
-
-
-
Method Detail
-
preInitialize
public void preInitialize(org.datanucleus.ClassLoaderResolver clr)
Pre initilize. For things that must be initialized right after constructor- Specified by:
preInitializein interfaceTable- Overrides:
preInitializein classAbstractTable- 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:
initializein interfaceTable- 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:
postInitializein interfaceTable- Overrides:
postInitializein classAbstractTable- Parameters:
clr- the ClassLoaderResolver
-
initializePK
protected void initializePK(org.datanucleus.ClassLoaderResolver clr)
Method to initialise the primary key of this table.- Specified by:
initializePKin classAbstractClassTable- 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:
getPrimaryKeyin classTableImpl- Returns:
- The primary key.
-
getPrimaryDatastoreClass
public DatastoreClass getPrimaryDatastoreClass()
Accessor for the primary datastore class that this is dependent on.- Specified by:
getPrimaryDatastoreClassin interfaceSecondaryDatastoreClass- 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:
getJoinMetaDatain interfaceSecondaryDatastoreClass- Returns:
- JoinMetaData
-
getIdentityType
public org.datanucleus.metadata.IdentityType getIdentityType()
Accessor for the identity-type. Simply returns the same as the primary table- Specified by:
getIdentityTypein interfaceDatastoreClass- Specified by:
getIdentityTypein classAbstractClassTable- Returns:
- identity-type tag value
-
getType
public String getType()
Accessor for the main type represented here.- Specified by:
getTypein interfaceDatastoreClass- 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:
isObjectIdDatastoreAttributedin interfaceDatastoreClass- Specified by:
isObjectIdDatastoreAttributedin classAbstractClassTable- 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:
isBaseDatastoreClassin interfaceDatastoreClass- Returns:
- true if this table is a root table
-
getBaseDatastoreClass
public DatastoreClass getBaseDatastoreClass()
Description copied from interface:DatastoreClassAccessor for the base datastore class. Returns this object if it has no superclass table, otherwise goes up to the superclass etc.- Specified by:
getBaseDatastoreClassin interfaceDatastoreClass- Returns:
- The base datastore class
-
getBaseDatastoreClassWithMember
public DatastoreClass getBaseDatastoreClassWithMember(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Convenience accessor for the base table for this table which has the specified member.- Specified by:
getBaseDatastoreClassWithMemberin interfaceDatastoreClass- Parameters:
mmd- MetaData for this member- Returns:
- The base table which has the member specified
-
getSuperDatastoreClass
public DatastoreClass getSuperDatastoreClass()
Accessor for the supertable for this table.- Specified by:
getSuperDatastoreClassin interfaceDatastoreClass- Returns:
- The supertable
-
isSuperDatastoreClass
public boolean isSuperDatastoreClass(DatastoreClass table)
Accessor whether the supplied DatastoreClass is a supertable of this table.- Specified by:
isSuperDatastoreClassin interfaceDatastoreClass- Parameters:
table- The DatastoreClass to check- Returns:
- Whether it is a supertable (somewhere up the inheritance tree)
-
getSecondaryDatastoreClasses
public Collection getSecondaryDatastoreClasses()
Accessor for any secondary tables for this table.- Specified by:
getSecondaryDatastoreClassesin interfaceDatastoreClass- Returns:
- Secondary tables (if any)
-
managesClass
public boolean managesClass(String className)
Accessor for whether this table manages the specified class.- Specified by:
managesClassin interfaceDatastoreClass- Parameters:
className- Name of the class- Returns:
- Whether it is managed by this table
-
getManagedClasses
public String[] getManagedClasses()
Description copied from interface:DatastoreClassAccessor for the names of all classes managed by this table.- Specified by:
getManagedClassesin interfaceDatastoreClass- Returns:
- Names of the classes managed (stored) here
-
getExpectedForeignKeys
public List<ForeignKey> getExpectedForeignKeys(org.datanucleus.ClassLoaderResolver clr)
Accessor for the expected foreign keys for this table.- Overrides:
getExpectedForeignKeysin classTableImpl- Parameters:
clr- ClassLoader resolver- Returns:
- The expected foreign keys.
-
getMemberMapping
public JavaTypeMapping getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor for the member Mapping. Returns the mapping if it is present in this table.- Specified by:
getMemberMappingin interfaceDatastoreClass- Specified by:
getMemberMappingin interfaceTable- Parameters:
mmd- MetaData for this member- Returns:
- the Mapping for the member
-
getMemberMappingInDatastoreClass
public JavaTypeMapping getMemberMappingInDatastoreClass(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor for the mapping for the specified member only in this datastore class.- Specified by:
getMemberMappingInDatastoreClassin interfaceDatastoreClass- Parameters:
mmd- Metadata of the member- Returns:
- The Mapping for the member (or null if not present here)
-
getMemberMapping
public JavaTypeMapping getMemberMapping(String memberName)
Accessor for the mapping for the specified member. TODO Use of this is discouraged since the memberName is not fully qualified and if a superclass-table inheritance is used we could have 2 members of that name here.- Specified by:
getMemberMappingin interfaceDatastoreClass- Parameters:
memberName- Name of the member- Returns:
- The mapping for the member
-
getIdMapping
public JavaTypeMapping getIdMapping()
Accessor for the ID mapping for this table.- Specified by:
getIdMappingin interfaceTable- 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:
providePrimaryKeyMappingsin interfaceDatastoreClass- Specified by:
providePrimaryKeyMappingsin classAbstractClassTable- Parameters:
consumer- Consumer for the mappings
-
provideExternalMappings
public void provideExternalMappings(MappingConsumer consumer, MappingType mappingType)
Description copied from interface:DatastoreClassInstruction to provide all external mappings to the passed consumer.- Specified by:
provideExternalMappingsin interfaceDatastoreClass- Parameters:
consumer- The consumer for the mappingsmappingType- Type of external mapping to provide
-
provideUnmappedColumns
public void provideUnmappedColumns(MappingConsumer consumer)
Method to provide all unmapped columns to the consumer.- Specified by:
provideUnmappedColumnsin interfaceDatastoreClass- Parameters:
consumer- Consumer of information
-
getExternalMapping
public JavaTypeMapping getExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData fmd, MappingType mappingType)
Description copied from interface:DatastoreClassAccessor for the external mapping for the specified member of the specified mapping type. An external mapping is a mapping for which there is no member in the actual class to represent it (part of a relation). The type can be FK, FK discriminator, order, etc- Specified by:
getExternalMappingin interfaceDatastoreClass- Parameters:
fmd- MetaData for the (external) membermappingType- The type of mapping- Returns:
- The external mapping
-
getMetaDataForExternalMapping
public org.datanucleus.metadata.AbstractMemberMetaData getMetaDataForExternalMapping(JavaTypeMapping mapping, MappingType mappingType)
Description copied from interface:DatastoreClassAccessor for the owner member metadata for the specified external mapping of the specified type- Specified by:
getMetaDataForExternalMappingin interfaceDatastoreClass- Parameters:
mapping- The external mappingmappingType- The type of mapping- Returns:
- Member MetaData in the owner class
-
-