Class 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 Details

    • 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 Details

    • AbstractClassTable

      public AbstractClassTable(DatastoreIdentifier tableName, RDBMSStoreManager storeMgr)
      Constructor.
      Parameters:
      tableName - Name of the table
      storeMgr - Store Manager that is managing this instance
  • Method Details

    • 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
    • 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 namings
      refTable - The table that we use as reference
      clr - The ClassLoaderResolver
      cmd - 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 id
      refTable - Table used as a reference (if any)
      cmd - The MetaData for the class
    • 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 interface org.datanucleus.store.schema.table.Table
      Overrides:
      getSurrogateColumn in class AbstractTable
    • 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 interface Table
      Overrides:
      getSurrogateMapping in class AbstractTable
      Parameters:
      colType - Column type for the surrogate
      allowSuperclasses - 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 mappings
      mmds - MetaData for the members to provide mappings for
      includeSecondaryTables - 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 column
      consumer - Consumer for the mappings