Class AbstractClassTable
java.lang.Object
org.datanucleus.store.rdbms.table.AbstractTable
org.datanucleus.store.rdbms.table.TableImpl
org.datanucleus.store.rdbms.table.AbstractClassTable
- All Implemented Interfaces:
Table, org.datanucleus.store.schema.table.Table
- Direct Known Subclasses:
ClassTable, SecondaryTable
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 ColumnMapping(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- memberMappingsMap - the set of mappings relating to the fields in the class. The mappings are keyed by the FieldMetaData of the field. Any embedded field will have a single mapping here of type EmbeddedPCMapping, with a set of datastore mappings attached.
- datastoreIdMapping - the Identity mapping when using "datastore identity"
- pkMappings - the mappings for the primary key column(s).
- discriminatorMapping - mapping for any discriminator column. This is only used where classes share this table and some of them use "superclass-table" strategy
- versionMapping - mapping for any versioning column
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JavaTypeMappingMapping for any create timestamp column.protected JavaTypeMappingMapping for any create user column.protected JavaTypeMappingMapping for any datastore identity.protected JavaTypeMappingMapping for any discriminator column.protected org.datanucleus.metadata.DiscriminatorMetaDataMetaData for discriminator for objects stored in this table.protected intHighest absolute field/property number managed by this tableprotected JavaTypeMappingMapping for the overall "identity" of the table.protected Map<org.datanucleus.metadata.AbstractMemberMetaData, JavaTypeMapping> Mappings for members mapped to this table, keyed by the metadata for the member.protected JavaTypeMappingMapping for any multi-tenancy column.protected JavaTypeMapping[]Mappings for application identity (optional).protected JavaTypeMappingMapping for any soft-delete column.protected JavaTypeMappingMapping for any update timestamp column.protected JavaTypeMappingMapping for any update user column.protected JavaTypeMappingMapping for any version/timestamp column.protected org.datanucleus.metadata.VersionMetaDataMetaData for versioning of objects stored in this table.Fields inherited from class 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 -
Constructor Summary
ConstructorsConstructorDescriptionAbstractClassTable(DatastoreIdentifier tableName, RDBMSStoreManager storeMgr) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) final voidaddApplicationIdUsingClassTableId(org.datanucleus.metadata.ColumnMetaDataContainer columnContainer, DatastoreClass refTable, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.metadata.AbstractClassMetaData cmd) Utility to create the application identity columns and mapping.(package private) voidaddDatastoreId(org.datanucleus.metadata.ColumnMetaData columnMetaData, DatastoreClass refTable, org.datanucleus.metadata.AbstractClassMetaData cmd) Utility to create the datastore identity column and mapping.protected voidaddMemberMapping(JavaTypeMapping mapping) Utility to add the mapping for a member to the managed list.abstract org.datanucleus.metadata.IdentityTypeAccessor for the identity-type.protected JavaTypeMappinggetMappingForMemberName(String memberName) Accessor for the JavaTypeMapping that is handling the member of the specified (fully qualified) name.Convenience method to return the primary table.getSurrogateColumn(org.datanucleus.store.schema.table.SurrogateColumnType colType) getSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, boolean allowSuperclasses) Accessor for the mapping for the specified surrogate type.protected abstract voidinitializePK(org.datanucleus.ClassLoaderResolver clr) Method to initialise the table primary key field(s).abstract booleanAccessor for whether the table has its identity attributed by the datastore (e.g using autoincrement)booleanmanagesMapping(JavaTypeMapping mapping) Convenience method to return if this table manages the columns for the supplied mapping.booleanmanagesMember(String memberName) Convenience method for whether the (fully-specified) member is managed by this tablevoidprovideMappingsForMembers(MappingConsumer consumer, org.datanucleus.metadata.AbstractMemberMetaData[] mmds, boolean includeSecondaryTables) Provide the mappings to the consumer for all specified members.final voidprovideNonPrimaryKeyMappings(MappingConsumer consumer) Provide the mappings to the consumer for all non primary-key members mapped to this table.abstract voidprovidePrimaryKeyMappings(MappingConsumer consumer) Provide the mappings to the consumer for all primary-key members mapped to this table (for application identity).final voidprovideSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, MappingConsumer consumer) Accessor for a mapping for a surrogate column (if present).Methods inherited from class TableImpl
createConstraints, dropConstraints, getExpectedCandidateKeys, getExpectedForeignKeys, getExpectedIndices, getPrimaryKey, getSQLAddCandidateKeyStatements, getSQLAddFKStatements, getSQLCreateIndexStatements, getSQLCreateStatements, getSQLDropStatements, initializeColumnInfoForPrimaryKeyColumns, initializeColumnInfoFromDatastore, logMapping, validate, validateColumns, validateConstraints, validatePrimaryKeyMethods inherited from class 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, postInitialize, preInitialize, tableExistsInDatastore, toStringMethods inherited from interface Table
getIdMapping, getMemberMapping, initialize
-
Field Details
-
memberMappingsMap
Mappings for members mapped to this table, keyed by the metadata for the member. -
pkMappings
Mappings for application identity (optional). -
idMapping
Mapping for the overall "identity" of the table. -
datastoreIdMapping
Mapping for any datastore identity. -
versionMapping
Mapping for any version/timestamp column. -
discriminatorMapping
Mapping for any discriminator column. -
multitenancyMapping
Mapping for any multi-tenancy column. -
softDeleteMapping
Mapping for any soft-delete column. -
createUserMapping
Mapping for any create user column. -
updateUserMapping
Mapping for any update user column. -
createTimestampMapping
Mapping for any create timestamp column. -
updateTimestampMapping
Mapping for any update timestamp column. -
versionMetaData
protected org.datanucleus.metadata.VersionMetaData versionMetaDataMetaData for versioning of objects stored in this table. -
discriminatorMetaData
protected org.datanucleus.metadata.DiscriminatorMetaData discriminatorMetaDataMetaData for discriminator for objects stored in this table. -
highestMemberNumber
protected int highestMemberNumberHighest absolute field/property number managed by this table
-
-
Constructor Details
-
AbstractClassTable
Constructor.- Parameters:
tableName- Name of the tablestoreMgr- Store Manager that is managing this instance
-
-
Method Details
-
getPrimaryTable
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
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
Accessor for the JavaTypeMapping that is handling the member of the specified (fully qualified) name. Returns the first one that matches.- Parameters:
memberName- Name of the field/property- Returns:
- The java type mapping
-
managesMapping
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
-
addApplicationIdUsingClassTableId
final void addApplicationIdUsingClassTableId(org.datanucleus.metadata.ColumnMetaDataContainer columnContainer, DatastoreClass refTable, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.metadata.AbstractClassMetaData cmd) Utility to create the application identity columns and mapping. Uses the id mapping of the specified class table and copies the mappings and columns, whilst retaining the passed preferences for column namings. This is used to copy the PK mappings of a superclass table so we have the same PK.- Parameters:
columnContainer- The container of column MetaData with any namingsrefTable- The table that we use as referenceclr- The ClassLoaderResolvercmd- The ClassMetaData
-
addDatastoreId
void addDatastoreId(org.datanucleus.metadata.ColumnMetaData columnMetaData, DatastoreClass refTable, org.datanucleus.metadata.AbstractClassMetaData cmd) Utility to create the datastore identity column and mapping. This is used in 2 modes. The first is where we have a (primary) class table and we aren't creating the OID mapping as a FK to another class. The second is where we have a (secondary) class table and we are creating the OID mapping as a FK to the primary class. In the second case the refTable will be specified.- Parameters:
columnMetaData- The column MetaData for the datastore idrefTable- Table used as a reference (if any)cmd- The MetaData for the class
-
addMemberMapping
Utility to add the mapping for a member to the managed list.- Parameters:
mapping- The mapping for the member
-
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
-
getSurrogateColumn
- Specified by:
getSurrogateColumnin interfaceorg.datanucleus.store.schema.table.Table- Overrides:
getSurrogateColumnin classAbstractTable
-
getSurrogateMapping
public JavaTypeMapping getSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, boolean allowSuperclasses) Description copied from interface:TableAccessor for the mapping for the specified surrogate type.- Specified by:
getSurrogateMappingin interfaceTable- Overrides:
getSurrogateMappingin classAbstractTable- Parameters:
colType- Column type for the surrogateallowSuperclasses- Whether to allow searching superclasses when not specified in this table.- Returns:
- The mapping
-
providePrimaryKeyMappings
Provide the mappings to the consumer for all primary-key members mapped to this table (for application identity).- Parameters:
consumer- Consumer for the mappings
-
provideNonPrimaryKeyMappings
Provide the mappings to the consumer for all non primary-key members mapped to this table.- Parameters:
consumer- Consumer for the mappings
-
provideMappingsForMembers
public void provideMappingsForMembers(MappingConsumer consumer, org.datanucleus.metadata.AbstractMemberMetaData[] mmds, boolean includeSecondaryTables) Provide the mappings to the consumer for all specified members.- Parameters:
consumer- Consumer for the mappingsmmds- MetaData for the members to provide mappings forincludeSecondaryTables- Whether to provide members in secondary tables
-
provideSurrogateMapping
public final void provideSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, MappingConsumer consumer) Accessor for a mapping for a surrogate column (if present).- Parameters:
colType- The type of the surrogate columnconsumer- Consumer for the mappings
-