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
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 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
Fields Modifier and Type Field Description protected JavaTypeMapping
createTimestampMapping
Mapping for any create timestamp column.protected JavaTypeMapping
createUserMapping
Mapping for any create user column.protected JavaTypeMapping
datastoreIdMapping
Mapping for any datastore identity.protected 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 tableprotected JavaTypeMapping
idMapping
Mapping for the overall "identity" of the table.protected Map<org.datanucleus.metadata.AbstractMemberMetaData,JavaTypeMapping>
memberMappingsMap
Mappings for members mapped to this table, keyed by the metadata for the member.protected JavaTypeMapping
multitenancyMapping
Mapping for any multi-tenancy column.protected JavaTypeMapping[]
pkMappings
Mappings for application identity (optional).protected JavaTypeMapping
softDeleteMapping
Mapping for any soft-delete column.protected JavaTypeMapping
updateTimestampMapping
Mapping for any update timestamp column.protected JavaTypeMapping
updateUserMapping
Mapping for any update user column.protected 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, 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
Constructors Constructor Description AbstractClassTable(DatastoreIdentifier tableName, RDBMSStoreManager storeMgr)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addMemberMapping(JavaTypeMapping mapping)
Utility to add the mapping for a member to the managed list.abstract org.datanucleus.metadata.IdentityType
getIdentityType()
Accessor for the identity-type.protected JavaTypeMapping
getMappingForMemberName(String memberName)
Accessor for the JavaTypeMapping that is handling the member of the specified (fully qualified) name.Table
getPrimaryTable()
Convenience method to return the primary table.Column
getSurrogateColumn(org.datanucleus.store.schema.table.SurrogateColumnType colType)
JavaTypeMapping
getSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, boolean allowSuperclasses)
Accessor for the mapping for the specified surrogate type.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(JavaTypeMapping mapping)
Convenience method to return if this table manages the columns for the supplied mapping.boolean
managesMember(String memberName)
Convenience method for whether the (fully-specified) member is managed by this tablevoid
provideMappingsForMembers(MappingConsumer consumer, org.datanucleus.metadata.AbstractMemberMetaData[] mmds, boolean includeSecondaryTables)
Provide the mappings to the consumer for all specified members.void
provideNonPrimaryKeyMappings(MappingConsumer consumer)
Provide the mappings to the consumer for all non primary-key members mapped to this table.abstract void
providePrimaryKeyMappings(MappingConsumer consumer)
Provide the mappings to the consumer for all primary-key members mapped to this table (for application identity).void
provideSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, MappingConsumer consumer)
Accessor for a mapping for a surrogate column (if present).-
Methods inherited from class org.datanucleus.store.rdbms.table.TableImpl
createConstraints, dropConstraints, getExpectedCandidateKeys, getExpectedForeignKeys, getExpectedIndices, getPrimaryKey, 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, postInitialize, preInitialize, 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
getIdMapping, getMemberMapping, initialize
-
-
-
-
Field Detail
-
memberMappingsMap
protected Map<org.datanucleus.metadata.AbstractMemberMetaData,JavaTypeMapping> memberMappingsMap
Mappings for members mapped to this table, keyed by the metadata for the member.
-
pkMappings
protected JavaTypeMapping[] pkMappings
Mappings for application identity (optional).
-
idMapping
protected JavaTypeMapping idMapping
Mapping for the overall "identity" of the table.
-
datastoreIdMapping
protected JavaTypeMapping datastoreIdMapping
Mapping for any datastore identity.
-
versionMapping
protected JavaTypeMapping versionMapping
Mapping for any version/timestamp column.
-
discriminatorMapping
protected JavaTypeMapping discriminatorMapping
Mapping for any discriminator column.
-
multitenancyMapping
protected JavaTypeMapping multitenancyMapping
Mapping for any multi-tenancy column.
-
softDeleteMapping
protected JavaTypeMapping softDeleteMapping
Mapping for any soft-delete column.
-
createUserMapping
protected JavaTypeMapping createUserMapping
Mapping for any create user column.
-
updateUserMapping
protected JavaTypeMapping updateUserMapping
Mapping for any update user column.
-
createTimestampMapping
protected JavaTypeMapping createTimestampMapping
Mapping for any create timestamp column.
-
updateTimestampMapping
protected JavaTypeMapping updateTimestampMapping
Mapping for any update 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.
-
highestMemberNumber
protected int highestMemberNumber
Highest absolute field/property number managed by this table
-
-
Constructor Detail
-
AbstractClassTable
public AbstractClassTable(DatastoreIdentifier tableName, RDBMSStoreManager storeMgr)
Constructor.- Parameters:
tableName
- Name of the tablestoreMgr
- Store Manager that is managing this instance
-
-
Method Detail
-
getPrimaryTable
public Table 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
public boolean managesMember(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 JavaTypeMapping getMappingForMemberName(String memberName)
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
public boolean managesMapping(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(JavaTypeMapping mapping)
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
public Column getSurrogateColumn(org.datanucleus.store.schema.table.SurrogateColumnType colType)
- Specified by:
getSurrogateColumn
in interfaceorg.datanucleus.store.schema.table.Table
- Overrides:
getSurrogateColumn
in classAbstractTable
-
getSurrogateMapping
public JavaTypeMapping getSurrogateMapping(org.datanucleus.store.schema.table.SurrogateColumnType colType, boolean allowSuperclasses)
Description copied from interface:Table
Accessor for the mapping for the specified surrogate type.- Specified by:
getSurrogateMapping
in interfaceTable
- Overrides:
getSurrogateMapping
in classAbstractTable
- Parameters:
colType
- Column type for the surrogateallowSuperclasses
- Whether to allow searching superclasses when not specified in this table.- Returns:
- The mapping
-
providePrimaryKeyMappings
public abstract void providePrimaryKeyMappings(MappingConsumer consumer)
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
public final void provideNonPrimaryKeyMappings(MappingConsumer consumer)
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
-
-