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 DatastoreClass
getBaseDatastoreClass()
Accessor for the base datastore class.DatastoreClass
getBaseDatastoreClassWithMember(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.JavaTypeMapping
getExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData fmd, MappingType mappingType)
Accessor for the external mapping for the specified member of the specified mapping type.org.datanucleus.metadata.IdentityType
getIdentityType()
Accessor for the identity-type.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.String[]
getManagedClasses()
Accessor for the names of all classes managed by this table.JavaTypeMapping
getMemberMapping(String memberName)
Accessor for the mapping for the specified member.JavaTypeMapping
getMemberMapping(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor for the member Mapping.JavaTypeMapping
getMemberMappingInDatastoreClass(org.datanucleus.metadata.AbstractMemberMetaData mmd)
Accessor for the mapping for the specified member only in this datastore class.org.datanucleus.metadata.AbstractMemberMetaData
getMetaDataForExternalMapping(JavaTypeMapping mapping, MappingType mappingType)
Accessor for the owner member metadata for the specified external mapping of the specified typeDatastoreClass
getPrimaryDatastoreClass()
Accessor for the primary datastore class that this is dependent on.PrimaryKey
getPrimaryKey()
Accessor for the primary key for this table.Collection
getSecondaryDatastoreClasses()
Accessor for any secondary tables for this table.DatastoreClass
getSuperDatastoreClass()
Accessor for the supertable for this table.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 datastoreboolean
isSuperDatastoreClass(DatastoreClass table)
Accessor whether the supplied DatastoreClass is a supertable of this table.boolean
managesClass(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(MappingConsumer consumer, MappingType mappingType)
Instruction to provide all external mappings to the passed consumer.void
providePrimaryKeyMappings(MappingConsumer consumer)
Provide the mappings to the consumer for all primary-key fields mapped to this table (for application identity).void
provideUnmappedColumns(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:
preInitialize
in interfaceTable
- Overrides:
preInitialize
in 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:
initialize
in 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:
postInitialize
in interfaceTable
- Overrides:
postInitialize
in classAbstractTable
- 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 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:
getPrimaryKey
in classTableImpl
- Returns:
- The primary key.
-
getPrimaryDatastoreClass
public DatastoreClass getPrimaryDatastoreClass()
Accessor for the primary datastore class that this is dependent on.- Specified by:
getPrimaryDatastoreClass
in 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:
getJoinMetaData
in 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:
getIdentityType
in interfaceDatastoreClass
- Specified by:
getIdentityType
in classAbstractClassTable
- Returns:
- identity-type tag value
-
getType
public String getType()
Accessor for the main type represented here.- Specified by:
getType
in 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:
isObjectIdDatastoreAttributed
in interfaceDatastoreClass
- Specified by:
isObjectIdDatastoreAttributed
in 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:
isBaseDatastoreClass
in interfaceDatastoreClass
- Returns:
- true if this table is a root table
-
getBaseDatastoreClass
public DatastoreClass getBaseDatastoreClass()
Description copied from interface:DatastoreClass
Accessor for the base datastore class. Returns this object if it has no superclass table, otherwise goes up to the superclass etc.- Specified by:
getBaseDatastoreClass
in 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:
getBaseDatastoreClassWithMember
in 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:
getSuperDatastoreClass
in interfaceDatastoreClass
- Returns:
- The supertable
-
isSuperDatastoreClass
public boolean isSuperDatastoreClass(DatastoreClass table)
Accessor whether the supplied DatastoreClass is a supertable of this table.- Specified by:
isSuperDatastoreClass
in 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:
getSecondaryDatastoreClasses
in interfaceDatastoreClass
- Returns:
- Secondary tables (if any)
-
managesClass
public boolean managesClass(String className)
Accessor for whether this table manages the specified class.- Specified by:
managesClass
in interfaceDatastoreClass
- Parameters:
className
- Name of the class- Returns:
- Whether it is managed by this table
-
getManagedClasses
public String[] getManagedClasses()
Description copied from interface:DatastoreClass
Accessor for the names of all classes managed by this table.- Specified by:
getManagedClasses
in 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:
getExpectedForeignKeys
in 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:
getMemberMapping
in interfaceDatastoreClass
- Specified by:
getMemberMapping
in 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:
getMemberMappingInDatastoreClass
in 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:
getMemberMapping
in 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:
getIdMapping
in 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:
providePrimaryKeyMappings
in interfaceDatastoreClass
- Specified by:
providePrimaryKeyMappings
in classAbstractClassTable
- Parameters:
consumer
- Consumer for the mappings
-
provideExternalMappings
public void provideExternalMappings(MappingConsumer consumer, MappingType mappingType)
Description copied from interface:DatastoreClass
Instruction to provide all external mappings to the passed consumer.- Specified by:
provideExternalMappings
in 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:
provideUnmappedColumns
in interfaceDatastoreClass
- Parameters:
consumer
- Consumer of information
-
getExternalMapping
public JavaTypeMapping getExternalMapping(org.datanucleus.metadata.AbstractMemberMetaData fmd, MappingType mappingType)
Description copied from interface:DatastoreClass
Accessor 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:
getExternalMapping
in 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:DatastoreClass
Accessor for the owner member metadata for the specified external mapping of the specified type- Specified by:
getMetaDataForExternalMapping
in interfaceDatastoreClass
- Parameters:
mapping
- The external mappingmappingType
- The type of mapping- Returns:
- Member MetaData in the owner class
-
-