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 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 table
        storeMgr - 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 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 fieldMapping)
        Utility to add the mapping for a field/property to the managed list.
        Parameters:
        fieldMapping - The mapping for the field/property
      • 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 fields 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 fields 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